Search code examples
blackberrycelltablelayout

Perform specific action when any cell of TableLayoutManager clicked


I'm new to Blackberry development. Currently, i have an instance of TableLayoutManager to add into the UI screen. How i perform a specific action when any cell of the table is selected/clicked, as the method setOnItemClick() i used in Android?

This is my code

TableLayoutManager colFMgr = new TableLayoutManager(new int[] {
TableLayoutManager.USE_PREFERRED_SIZE,
TableLayoutManager.USE_PREFERRED_SIZE }, new int[] {
TableLayoutManager.USE_PREFERRED_WIDTH_WITH_MAXIMUM,
TableLayoutManager.USE_PREFERRED_WIDTH_WITH_MAXIMUM }, 5,
Manager.HORIZONTAL_SCROLL);
for (int i = 0; i < images.length; i++) {
    colFMgr.add(new BitmapField(images[i], Field.FOCUSABLE));
}
add(colFMgr);

TableLayoutManager is a class as defined here

I want to do specific action (like navigating to other screen) when any cell of the table clicked and get information about which cell is clicked.

Thank you...


Solution

  • I didnt tried this answer. Lets check it.

    TableLayoutManager colFMgr = new TableLayoutManager(new int[] {
    TableLayoutManager.USE_PREFERRED_SIZE,
    TableLayoutManager.USE_PREFERRED_SIZE }, new int[] {
    TableLayoutManager.USE_PREFERRED_WIDTH_WITH_MAXIMUM,
    TableLayoutManager.USE_PREFERRED_WIDTH_WITH_MAXIMUM }, 5,
    Manager.HORIZONTAL_SCROLL){
        protected boolean navigationClick(int status, int time) { 
            int k=getFieldWithFocusIndex(); 
                if(k==0){
                    //clicked first row
                }else if(k==1){
                    //clicked second row
                }//and so on......
            return true; 
           } 
    
        };
    
    for (int i = 0; i < images.length; i++) {
        colFMgr.add(new BitmapField(images[i], Field.FOCUSABLE));
        }
    add(colFMgr);