1

我是 android 新手,我正在一个想要滑动我的布局的应用程序中工作。是否可以将布局绑定到 android 小部件库。或者请告诉我在 android 中滑动我的布局的最佳做法。

如果可能,请帮助我提供有效的链接

提前致谢。

我的主要课程

public class GalleryTestActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Gallery gallery = (Gallery) findViewById(R.id.gallery);
        gallery.setAdapter(new ImageAdapter(this));


}
}

我的基类

public class ImageAdapter extends BaseAdapter {
    int mGalleryItemBackground;
    private Activity mContext;
    private Gallery mGallery; 


    private Integer[] mImageIds = {
            R.layout.instruction,
            R.layout.instruction2

    };

    public ImageAdapter(Activity c)
    {
        mContext=c;
        TypedArray attr = mContext.obtainStyledAttributes(R.styleable.HelloGal999lery);
        mGalleryItemBackground = attr.getResourceId(
                R.styleable.HelloGal999lery_android_galleryItemBackground, 100);
        attr.recycle();
    }



    public int getCount() {
        return mImageIds.length;
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
            //Help me here
        View rowView = convertView;
        if(rowView==null)
        {
            LayoutInflater inflater = mContext.getLayoutInflater();
             rowView = inflater.inflate(mImageIds[position], null, true);
        }
        return rowView;

    }
}
4

1 回答 1

0

您可以使用Gallery.

或者有新的小部件ViewPager或者在 android 支持包中

这里是关于ViewPager

也是一个很好的关于ViewPager使用的存储库。

于 2012-04-24T06:25:21.507 回答