5
我有2個ListView在一個單一的片段,我不知道我是否可以爲同一個類實現AdapterView.OnItemClickListener設置。AdapterView.OnItemClickListener與更多的ListView
我的意思是,Android文檔說:
public abstract void onItemClick (AdapterView<?> parent, View view, int position, long id)
Added in API level 1
Callback method to be invoked when an item in this AdapterView has been clicked.
Implementers can call getItemAtPosition(position) if they need to access the data associated with the selected item.
Parameters
parent The AdapterView where the click happened.
view The view within the AdapterView that was clicked (this will be a view provided by the adapter)
position The position of the view in the adapter.
id The row id of the item that was clicked.
所以我想,我可以選擇不同的ListView與調用的onClick由父(適配器視圖點擊這裏發生)..
現在,我怎麼能確定的ListView ?有沒有辦法讓swicth/case?或者我需要創建不同的類(也可以匿名我知道),實現onItemClickListener並設置爲不同ListView不同AdapterView.onItemClickListener?
靶心!非常感謝答案。解決了。 –