Jon Willis发布了如何使用他的代码实现无限滚动.在那里,他说他在Android支持库的ViewPager类中进行了一些更改.已经进行了哪些更改以及如何使用ViewPager更改"重新编译"库?
如Google所述,Gallery类在API级别16中已弃用.不再支持此小部件.其他水平滚动小部件包括支持库中的HorizontalScrollView和ViewPager.所以我使用ViewPager作为Gallery类的替代品.
我的目标是最终实现带有文本描述的无限滚动图像ViewPager.我使用下面的代码来实现图像ViewPager,其中包含描述每个图像的文本但是如何将无限滚动应用于ViewPager?
我之前没有使用过ViewPager,请尽量提供详细的代码.
activity_main.xml中:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:orientation="vertical">
  <android.support.v4.view.ViewPager 
       android:id="@+id/myimagepager" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" /> 
</LinearLayout>
custom_pager.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
   android:layout_width="match_parent" 
   android:layout_height="match_parent" 
   android:orientation="vertical"  
   android:gravity="center_horizontal">
   <ImageView 
       android:id="@+id/myimage" 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_margin="5dp" 
       android:layout_weight="2" /> 
    <TextView 
       android:id="@+id/image_text" 
       android:layout_width="fill_parent" 
       android:layout_height="0dp"   
       android:layout_weight="1"/>
</LinearLayout>
ImagePager:
public class ImagePager extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ImagePagerAdapter adapter = new ImagePagerAdapter(this, imageArra, stringArray );
        ViewPager myPager = (ViewPager) findViewById(R.id.myimagepager);
        myPager.setAdapter(adapter);
        myPager.setCurrentItem(0);
    }
    private int imageArra[] = { R.drawable.a, R.drawable.b,R.drawable.c, 
                                 R.drawable.d,R.drawable.e,R.drawable.f,
                                 R.drawable.g, …我一直在使用CWAC的EndlessAdapter在ListViews上实现无限滚动.
我想完成ViewPager的等价物.遗憾的是,PageAdapter和ListAdapter不共享相同的公共基类.
最好的方法是什么?是否存在已经处理此问题的库?