2013-05-14 87 views
2

我正在使用網格視圖,在這種情況下,我需要點擊並通過顯示一個小圖像來選擇圖像。正如您在附件中看到的那樣,圖像上的綠色標記顯示它們已被選中。這在Normal Grid視圖中是不可能的。我試過這個。創建自定義網格視圖以在android中顯示所選圖像

請給我建議。

enter image description here

+0

http://stackoverflow.com/questions/7661019/keep-image-in-gridview-selected – Sam 2013-05-14 09:05:40

回答

2

從谷歌傢伙已經做了一切爲您解決您的問題 所以,你必須在你的Activity中使用ActionMode並填充你的GridView。

http://developer.android.com/guide/topics/ui/menus.html#context-menu

所以當你進入ActionMode只設置在ChoiceMode->多你的GridView對象。

在你的代碼:

GridView gv=new GridView(this) or this.findViewById(R.id.ma_grid_view); 
GridAdapter adapter... 
gv.setAdapter(adapter) 
beginActionMode(); // this might be used by a long press or by button tam in action bar... 

public void beginActionMode(){ 
    gv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); 
} 

還挺喜歡這樣,閱讀文章心中已經發送給您 花一些houres,你會到達它... 感謝。