Currently when i click on any list item, it get index of of first clicked list item index, means if i click on videos, it save video click index even when i click on images it shows video data. i want when i click on any item it shows only that selected index data and that is possible i get selected item list title dynamically ??
Vector v = new Vector();
for (int i = 0; i < 3; i++) {
final String listTitle = _folderList[i]._fileName;
v.addElement(new ListRander(closedIcon, listTitle, playIcon));
// CustomListField With Event
myListView = new CustomListField(v) {
public boolean trackwheelClick(int status, int time) {
// which row is selected?
int index = getSelectedIndex();
if (index == 0) {
String ImageIndex = "Images";
UiApplication.getUiApplication().pushScreen(new ImagesList(ImageIndex, _ftp));
}
if (index == 1) {
String MusicIndex = "Music";
UiApplication.getUiApplication().pushScreen(new MusicList(MusicIndex, _ftp));
}
if (index == 2) {
String VideoIndex = "Video";
UiApplication.getUiApplication().pushScreen(new VideosList(VideoIndex, _ftp));
}
return true;
}
};
}// For Loop End
add(myListView);
You might want to return
super.trackwheelClick()
instead.Returning true means that the event is consumed. As you dont call the parent class handler, your list can't know it has been clicked, and it returns the last selected item (which is the first element by default).
As a final tip: don't use
trackwheelClick
, because it wont work in touchscreen enabled devices. UsenavigationClick
orFieldChangeListener
instead.