English 中文(简体)
如何显示和隐藏在黑莓点击名单上的形象?
原标题:How to Display and hide an image in list on clicking on it in blackberry?

hi i created a CustomListField and implemented "drawListRow" method to draw an image,text and another image in a row. now when i click on the list,image on the right side should disappear. when i again click on the list it should appear again. how to do this. Please post the code.

问题回答

You re going to have to keep track of what rows have been clicked (and therefore have images which are hidden) and which have not. I would use an array of booleans to do this.

Override the keyDown method in your CustomListField and use getSelectedIndex to figure out which row is currently selected.

阁下的DelListRow方法指出,清单现场被作为参数通过,把这个数据带回海关,并采用一种称为“RowClicked(intindex)”的新方法,该方法可回收该行是否被点击,因此,应当利用或没有适当的手图。

大致如下:

public class CustomListField extends ListField implements ListFieldCallback{

    private static final int TOTAL_ROWS = 10; //total number of rows in list
    private boolean[] clickedRows = new boolean[TOTAL_ROWS];

    public CustomListField(){
        //do all your instantiation stuff here
    }

    public boolean keyDown(int keycode, int time){

        int currentlySelectedRow = getSelectedIndex();

                //toggle the state of this row
                clickedRows[currentlySelectedRow] = !clickedRows[currentlySelectedRow];

        //consume the click
        return true;
    }

    public boolean isRowClicked(int index){
        return clickedRows[index];
    }

    public void drawListRow(ListField listField, Graphics graphics, int index,
        int y, int width) {

        CustomListField customListfield = (CustomListField) listField;

                //check whether this row is clicked 
                if(customListfield.isRowClicked(index)){

            //draw the state when the row is clicked

        } else {

            //draw the row when the row is not clicked
        }

    }

}




相关问题
How does AlertListener work on Blackberry API 5.0?

Does the AlertListener interface works globally on all alerts on the blackberry device, or does it only work with alerts generated by your application? In other words, can I use this interface to ...

How to buffer audio in Blackberry?

I need to learn how to buffer audio stream from a remote server in Blackberry. There is a sample buffered playback app with Blackberry api but can you tell what url may I use to test the application?

Blackberry push notification implementation

How does one implement a push notification for a blackberry app? I heard that in order to do so I need to purchase a Blackberry Enterprise Server which costs me 1400 per year. Is this true? Where is ...

热门标签