Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 34
Registered: ‎03-08-2012
My Device: Simulator
My Carrier: Developer

Refreshing Table Adapter screen : Blackberry

Is there any way to refresh Table Adapter Screen on button click. If i m callling table method again on button click then it is adding a new table adapter screen below the old on.....I s there any way to refresh the existing screen.The button is deleting elements from table after which i want to refresh table adapter screen.



public static void richlistshow(){
        int ik = target_list.size()-1;
       while(ik > 0 )
           Bitmap logoBitmap = Bitmap.getBitmapResource("delete.png");       

           City aCity = (City)target_list.elementAt(ik);
           String modelNumber = aCity.get_city_name().toString();
           String modelName = " X ";
           //String ne = String.valueOf(ik);
           String date_time = "  Date-Time";

           Object[] row = {modelName, modelNumber,date_time,logoBitmap};

     TableView tableView = new TableView(_tableModel);
     tableView.setDataTemplateFocus(BackgroundFactory.createLinearGradientBackground(Color.YELLOWGREEN, Color.LIMEGREEN, Color.SEAGREEN, Color.SANDYBROWN));
     TableController tableController = new TableController(_tableModel, tableView);

     // Specify a simple data template for displaying 3 columns
     DataTemplate dataTemplate = new DataTemplate(tableView, NUM_ROWS, NUM_COLUMNS)
         public Field[] getDataFields(int modelRowIndex)
             //final int i =modelRowIndex;
             Object[] data = (Object[]) (_tableModel.getRow(modelRowIndex));

             final String cname = (String)data[1];

             /****** Declaring button for deletion of record from database ******/
             ButtonField delete =new ButtonField("X",ButtonField.CONSUME_CLICK);

             /*******  Setting change listener and defining field change within *******/
             delete.setChangeListener(new FieldChangeListener() {

             /*******  defining what should happen when button is clicked ********/
                public void fieldChanged(Field field, int context) {

                    DatabaseHandler delete_row = new DatabaseHandler();

            /****calling function to retrieve values from the databasse table.***/
            /****************calling method again to show the updated values*************/      
                richlistshow();//for showing refreshed data after deletion of a record


             Field[] fields = {delete, new LabelField((String) data[1]), new LabelField((String) data[2]),new BitmapField((Bitmap)data[3])};
             return fields;



     // Define regions and row height
     dataTemplate.setRowProperties(0, new TemplateRowProperties(ROW_HEIGHT));

     for(int i = 0; i < NUM_COLUMNS; i++)
         dataTemplate.createRegion(new XYRect(i, 0, 1, 1));
         dataTemplate.setColumnProperties(i, new TemplateColumnProperties(Display.getWidth() / NUM_COLUMNS));

     // Apply the template to the view




public final static class MyCity
    private String _name;
    private String _datetime;
    private String _button;
    private Bitmap _bitmap;

    MyCity(String name, String datetime, String button, Bitmap bitmap)
        _name = name;
        _datetime = datetime;
        _button = button;
        _bitmap = bitmap;

    public String getName()
        return _name;
    public String getDatetime()
        return _datetime;
    public String getButton()
        return _button;
    public Bitmap getBitmap()
        return _bitmap;

/****************TABLE CONTROLLER CLASS ******************/
 private class CityTableModelAdapter extends TableModelAdapter
        public int getNumberOfRows()
            return _cities.size();
        public int getNumberOfColumns()
            return NUM_COLUMNS;
        protected boolean doAddRow(Object row)
            Object[] arrayRow = (Object[]) row;

            System.out.println("! : "+arrayRow[0]+" @: "+arrayRow[1]+" #: "+arrayRow[2]);

            _cities.addElement(new MyCity((String) arrayRow[0], (String) arrayRow[1], (String) arrayRow[2], (Bitmap) arrayRow[3]));
            return true;
        protected Object doGetRow(int index)
            MyCity mycity = (MyCity) _cities.elementAt(index);

            Object[] row = {mycity.getName(),mycity.getDatetime(),mycity.getButton(),mycity.getBitmap()};

            return row;