登录 注册
当前位置:主页 > 资源下载 > 27 > Google Play中的ListView和GridView实现了下拉刷新及上拉加载更多功能,同时解决了图片加载OOM问题

Google Play中的ListView和GridView实现了下拉刷新及上拉加载更多功能,同时解决了图片加载OOM问题

  • 更新:2024-05-22 21:06:44
  • 大小:1.33MB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:Android - 移动开发
  • 格式:RAR

资源介绍

android 仿google play效果,ListView/GridView下拉刷新,上拉加载更多,自动加载异步请求数据以及分页数据 package net.xinhua.activity; import net.xinhuamm.widget.TouchViewPager; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.view.ViewConfiguration; import android.widget.Toast; import com.viewpagerindicator.TabPageIndicator; /** * @类名:ViewPagerListViewActivity * @描述:TODO(左右滑动) * @作者:zhaohao * @时间 2013-7-1 上午11:23:33 */ public class ViewPagerListViewActivity extends FragmentActivity { private static final String[] CONTENT = new String[] { "头条娱乐", "汽车世界", "风景", "动物世界","美图","图文展示", "各地风俗","美食天下","军事","一周军事看点"}; private int touchSlop; TouchViewPager pager =null; FragmentPagerAdapter adapter=null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_tabs); adapter = new GoogleMusicAdapter(getSupportFragmentManager()); pager = (TouchViewPager)findViewById(R.id.pager); pager.setAdapter(adapter); TabPageIndicator indicator = (TabPageIndicator)findViewById(R.id.indicator); indicator.setViewPager(pager); onTouch(); } class GoogleMusicAdapter extends FragmentPagerAdapter { public GoogleMusicAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { if("美图".equals(CONTENT[position])){ return GridContentActivity.newInstance(CONTENT[position]); }else{ return ContentActivity.newInstance(CONTENT[position]); } } @Override public CharSequence getPageTitle(int position) { return CONTENT[position % CONTENT.length]; } @Override public int getCount() { return CONTENT.length; } } public void onTouch() { touchSlop = ViewConfiguration.get(ViewPagerListViewActivity.this).getScaledTouchSlop(); pager.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_UP: float downX = pager.getDownX(); float lastX = event.getX(); float disX = Math.abs(lastX-downX); if(touchSlopdownX && pager.getCurrentItem()==0 ) { Toast.makeText(ViewPagerListViewActivity.this, "左滑关闭", 3).show(); }else if(touchSlop