2010-08-24 17 views
1

Hai All, 我有一個包含電影,音樂,遊戲,雜誌等文字值的圖庫,我的問題是,無論何時用戶滾動圖庫,我想獲得元素的位置。如何在用戶滾動時獲取圖庫中元素的位置?

對於實例, 用戶從電影滾動畫廊到遊戲意味着,那麼我必須得到當前選定元素的位置,即遊戲的位置。

由於事先

+0

請在庫控制 HTTP我的博客文章: //android-pro.blogspot.com/2010/07/android-gallery-control.html它可以幫助你 – 2010-08-24 11:15:26

回答

0

在你的OnCreate做財產以後這樣.....

{ 
gallery.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { 

      public void onItemSelected(AdapterView<?> arg0, View arg1, int pos ,long arg3) { 

       //you will have the selected position in variable pos 
       } 

} 

希望它會工作

相關問題