我是 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;
}
}