- 浏览: 687855 次
- 性别:
- 来自: 苏州
最新评论
-
usedlie:
if (flag) { matrix.set(matrix ...
android view的缩放平移简单实现 -
jin290:
简单 快捷 非常棒 可以直接用
android 应用实现微信好友或朋友圈分享 -
貌似掉线:
0是朋友1是朋友圈
android 应用实现微信好友或朋友圈分享 -
zhangzhanlei:
[color=red][/color]
android 应用实现微信好友或朋友圈分享 -
shizhangliao:
android适配多分辨率的小技巧
在使用listview时,滑动加载可以提高效率,增加用户体验。
主要用到一个OnScrollListener
主要用到一个OnScrollListener
/** * The view is not scrolling. Note navigating the list using the trackball counts as * being in the idle state since these transitions are not animated. */ public static int SCROLL_STATE_IDLE = 0; /** * The user is scrolling using touch, and their finger is still on the screen */ public static int SCROLL_STATE_TOUCH_SCROLL = 1; /** * The user had previously been scrolling using touch and had performed a fling. The * animation is now coasting to a stop */ public static int SCROLL_STATE_FLING = 2; /** * Callback method to be invoked while the list view or grid view is being scrolled. If the * view is being scrolled, this method will be called before the next frame of the scroll is * rendered. In particular, it will be called before any calls to * {@link Adapter#getView(int, View, ViewGroup)}. * * @param view The view whose scroll state is being reported * * @param scrollState The current scroll state. One of {@link #SCROLL_STATE_IDLE}, * {@link #SCROLL_STATE_TOUCH_SCROLL} or {@link #SCROLL_STATE_IDLE}. */ public void onScrollStateChanged(AbsListView view, int scrollState); /** * Callback method to be invoked when the list or grid has been scrolled. This will be * called after the scroll has completed * @param view The view whose scroll state is being reported * @param firstVisibleItem the index of the first visible cell (ignore if * visibleItemCount == 0) * @param visibleItemCount the number of visible cells * @param totalItemCount the number of items in the list adaptor */ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount);
package com.nico.listviewload; import java.util.ArrayList; import java.util.List; import com.nico.bean.MsgInfo; import android.app.Activity; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.BaseAdapter; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import android.widget.AbsListView.OnScrollListener; public class MainActivity extends Activity { List<MsgInfo> infoList = null; private LayoutInflater inflater = null; private ListView listview = null; private myAdapter adapter = null; private LinearLayout ftview = null; private Handler handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what){ case 1: adapter.notifyDataSetChanged(); try { Thread.sleep(2000l); } catch (InterruptedException e) { e.printStackTrace(); } setAdapter(); break; } } }; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); inflater = this.getLayoutInflater(); listview = (ListView) findViewById(R.id.listview); ftview = (LinearLayout) inflater.inflate(R.layout.ftview, null); listview.addFooterView(ftview, null, false); listview.setAdapter(new myAdapter()); adapter = new myAdapter(); ftview.setVisibility(View.VISIBLE); listview.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (scrollState == SCROLL_STATE_IDLE && view.getLastVisiblePosition() == view.getCount() - 1) { handler.sendEmptyMessage(1); } } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); } public List<MsgInfo> getList() { List<MsgInfo> infoList = new ArrayList<MsgInfo>(); for (int i = 0; i < 7; i++) { MsgInfo info = new MsgInfo(); info.id = i; info.detailinfo = "这是第" + i + "条信息"; info.name = "第" + i + "项"; info.size = 1024 * i; infoList.add(info); } return infoList; } public void setData() { infoList = getList(); } public void setAdapter() { for (int i = 0; i < 7; i++) { MsgInfo info = new MsgInfo(); info.id = i; info.detailinfo = "这是第" + i + "条信息"; info.name = "第" + i + "项"; info.size = 1024 * i; infoList.add(info); } adapter.notifyDataSetChanged(); } public class myAdapter extends BaseAdapter { @Override public void notifyDataSetChanged() { if(ftview.getVisibility()==View.VISIBLE) { ftview.setVisibility(View.GONE); } else if(ftview.getVisibility()==View.GONE) { ftview.setVisibility(View.VISIBLE); } super.notifyDataSetChanged(); } TextView name, detail, size; public myAdapter() { setData(); } @Override public int getCount() { return infoList.size(); } @Override public Object getItem(int position) { return infoList.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = inflater.inflate(R.layout.item, null, false); } name = (TextView) convertView.findViewById(R.id.name); detail = (TextView) convertView.findViewById(R.id.detail); size = (TextView) convertView.findViewById(R.id.size); name.setText(infoList.get(position).name); detail.setText(infoList.get(position).detailinfo); size.setText(infoList.get(position).size + ""); return convertView; } } public class LoadAsyTask extends AsyncTask<String, String, String> { @Override protected String doInBackground(String... params) { for (int i = 0; i < 7; i++) { MsgInfo info = new MsgInfo(); info.id = i; info.detailinfo = "这是第" + i + "条信息"; info.name = "第" + i + "项"; info.size = 1024 * i; infoList.add(info); } return null; } @Override protected void onPostExecute(String result) { super.onPostExecute(result); ftview.setVisibility(View.GONE); adapter.notifyDataSetChanged(); } } }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="fill_parent" android:gravity="center_horizontal" android:layout_height="wrap_content" android:layout_gravity="center_horizontal"> <ImageView android:layout_width="50dip" android:layout_height="50dip" android:src="@drawable/progressbar" android:id="@+id/pbdrawable" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="请稍后..." android:id="@+id/pbtxt" /> </LinearLayout> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0" android:toDegrees="360"> <shape android:shape="ring" android:innerRadiusRatio="3" android:thicknessRatio="8" android:useLevel="false"> <gradient android:type="sweep" android:useLevel="false" android:startColor="#000000" android:centerColor="#FFFFFF" android:centerY="0.50" android:endColor="#000000" /> </shape> </rotate>
发表评论
-
jar包混淆
2016-09-18 16:46 1068开发过程中需要把相关功能打成jar包供别人调用,如果不混淆的话 ... -
项目从eclipse移植到studio中遇到的问题整理
2016-09-13 17:42 1131概念 eclipse workspace ---> ... -
ViewGroup&View&Activity onInterceptTouchEvent&dispatchTouchEvent&onTouch整理
2016-08-03 22:26 624一直对这块的知识一知 ... -
仿京东android客户端收件地址选择
2016-07-12 18:07 6461纯手写,可能有些问题,功能已实现 activity pac ... -
FragmentActivity中资源被回收,导致页面fragment错乱的问题
2016-06-07 13:59 3789开发过程中,页面使用fragmentactivity,可能会遇 ... -
android 通过eclipse mat来监测应用内存
2016-02-03 13:02 011dasdasdas -
【转】详解ViewPager调用FragmentPagerAdapter.notifyDataSetChanged()不能更新Fragment
2016-01-30 13:27 2008转载自 http://www.blog4app.com/?p= ... -
startActivityForResult常用使用方式
2015-04-24 11:58 1669示例 初始Activity启动目标activity,并带上了请 ... -
在android4.4以上版本 第三方应用处理短信的疑惑
2015-03-31 16:14 975最近有个处理android手机短信的需求,需要删除本地某指定短 ... -
Beacon的入门相关知识整理(关于android开发)
2014-10-27 16:53 0To do.... -
[转]常用Github项目类库
2014-09-18 09:29 1745【转自】http://blog.csdn.net/jabony ... -
android适配多分辨率的小技巧
2014-09-05 18:10 2752android多分辨率适配其实是老生常谈的话了,今天再拿出来炒 ... -
android通过自定义schame和host来启动app
2014-08-15 15:02 2110很多时候,我们可以看到在web页面中点击链接,可以直接启动ap ... -
基础知识整理
2014-08-08 17:50 0onTouch(MotionEvent event) eve ... -
android view的缩放平移简单实现
2014-07-22 16:20 16314参考了下网上一些实现 主要是通过matrix实现的 用到的 ... -
android 应用实现微信好友或朋友圈分享
2014-07-18 16:44 60380官方的文档连接:https://open.weixin.qq. ... -
android 自定义view支持gif格式播放
2014-07-16 18:38 4105前段时间做了个项目,有播放gif的需求, 而android展示 ... -
android中自定义attr,以及style杂谈
2014-06-05 18:12 13700attr 属性 style 样式 二者都是在res/value ... -
ViewGroup中的onInterceptTouchEvent和onTouchEvent调用时序
2014-05-20 11:20 1125最近在做android类似slidemenu项目,遇到了scr ... -
获取手机网络状态的代码
2014-03-27 16:45 1252之前网上有人使用方法判断手机网络状态代码如下: Co ...
相关推荐
android中listview滚动加载的demo,通过监听事件实现滑动到底部自动加载更多数据
android Listview下拉刷新 上拉(滑动分页)加载更多,经典demo,供学习参考
http://blog.csdn.net/qq_32673327/article/details/52012327 这是关于Demo实现的博客
android自定义listview,实现了下拉刷新,滑动操作,以及上拉加载 。 demo是用android studio开发,测试
VideoListPlayer实现了在列表控件(ListView, RecyclerView)中加载并播放视频,并支持滑动时自动播放/暂停的功能 利用该项目,可以轻松实现类似Instagram的视频播放功能 注意:最低支持API 14以上 效果预览 ...
基于listView的树状列表实现, 向下滑动界面,从数据库里异步加载数据到listView显示
我们在看微博或是到网上商城如淘宝中购物时,每一个商家都会有很多商品,如果把某商家的所有商品都一次性加载过来,会造成手机卡顿,影响用户体验,所以每次加载少量数据,使用分页的形式,分多页加载,会很好的提高...
这个demo是有listview实现的,里面又ProgressBar提示正在加载的效果,还有listview显示列表数据,当道最地下面的时候,向上滑动页面,会有加载更多的功能及效果,实现分页的另一种效果
支持仿微信滑动删除,并且支持上拉加载更多数据,下拉刷新数据功能控件,里面有DEMO和APK,自己看吧,重新设置下分数
demo集刷新与滑动删除与一体,分享给大家 ,希望对大家有所帮助
Android market里软件列表,每页显示10条记录,没有显示上一页,下一页的按钮,依靠手滑动动态加载数据,当向下滚动时,最下边显示 Loading… 。数据加载结束,Loading底栏消失。关于ListView的分段显示,有现成的库...
Android应用开发中,采用ListView组件来展示数据是很常用的功能,当一个应用要展现很多的数据时,一般情况下都不会把所有的数据一次就展示出来,而是通过分页的形式来展示数据,个人觉得这样会有更好的用户体验。...
41、AIDL Service android中的跨进程调用 客户端,服务端见AidlService 42、BroadcastReceiver 接收广播消息 43、非UI线程中不能操作UI线程中的View测试 44、ImageSwitcher animation gesture实现可以滑动的跑马灯...
安卓源码包android web应用Dialog对话框OCR图像识别listview相关EditText输入框Launcher 桌面45个合集: [四次元]Android Launcher 桌面分页滑动代码.rar [四次元]Android Launcher 源码修改可编译.rar [四次元]...
结合下拉刷新上拉加载与右滑删除做了一个demo,供大家学习,互相进步。
16 AsyncTask进度条加载网站数据到ListView 17 EditText插入QQ表情源码 18 OpenGL的一个简单的例子 19闹钟 20 指南针 21 重力感应 22 android 查询工具源代码 23 android进度条对话框Demo 24 Android实现渐显按钮的...
DEMO实现了上下滑动加载,并实现了item的每个item的单机事件
本demo是将更新的监听放在listview的foot中,通过底部按钮点击触发或者通过滑动事件监听,当滑动到列表最底部的时候触发。 有图有真像: 列表初始状态 触发加载 加载后 部分代码: MainActivity 代码如下: private ...
Android ListView添加头布局和脚布局 之前学习喜马拉雅的时候做的一个小Demo,贴出来,供大家学习参考; 如果我们当前的页面有多个接口、多种布局的话,我们一般的选择无非就是1、多布局;2、各种复杂滑动布局外面...
异步加载适配器,异步或线程获取图片,图片的一级缓存,滑动时停止加载等优化. AndroidStudio项目