2012-04-24 3 views
1

私はアンドロイドを初めて使い、レイアウトをスワイプしたいアプリケーションで作業しています。アンドロイドウィジェットギャラリーにレイアウトをバインドすることは可能ですか?または、私のレイアウトをアンドロイドでスワイプするアドバイスをしてください。ギャラリーbingingレイアウト

可能な場合は事前に

おかげで有効なリンクで私を助けてください。

私の主なクラス

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; 

    } 
} 

答えて

0

あなたはGalleryを使用することができます。

またはアンドロイドサポートパッケージに新しいウィジェットViewPagerがあります。

HereViewPager

ThisViewPager使用状況に関する良いリポジトリでの素敵なチュートリアルです。

+0

こんにちはAdil Soomro、ギャラリーウィジェットを使うことができれば、どのウィジェットを使ってレイアウトをギャラリーウィジェットにバインドできますか?あなたの返信をありがとう – Arun

+1

'Gallery'ウィジェットは' ListView'と同じように実装されています。したがって、ビューを「ギャラリー」にバインドするアダプタが必要です。 –

+0

私は – Arun