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 に答える