Get selected index list title blackberry java

試著忘記壹切 提交于 2019-12-14 02:43:59

问题


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);

回答1:


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. Use navigationClick or FieldChangeListener instead.



来源:https://stackoverflow.com/questions/19914288/get-selected-index-list-title-blackberry-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!