listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
System.out.println(id);
System.out.println(files[(int)id].getAbsolutePath());
mp3Player = new MP3Player(MainActivity.this);
mp3Player.init(files[(int)id].getName());
mp3Player.play();
}
});
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { //長按事件
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
System.out.println("22222222222222222222222222222222");
System.out.println(files[(int)id].getAbsolutePath());
return true;
}
});
Android studio 47 listview 處理單擊和長按事件
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.