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 处理单击和长按事件
最新推荐文章于 2022-04-10 20:35:02 发布