Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 414857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:19:26+00:00 2026-05-12T18:19:26+00:00

here is my app. how to add table view or grids in the following.

  • 0

here is my app. how to add table view or grids in the following.
should i draw every thing plz help
this is my code

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.device.api.util.*;
import java.util.*;


/*An application in which user enters the data. this data is displayed when user press the save button*/



public class Display extends UiApplication {

 /*declaring Strings to store the data of the user*/

 String getFirstName;
 String getLastName;
 String getEmail;
 String getGender;
 String getStatus;

 /*declaring text fields for user input*/
 private AutoTextEditField firstName;

 private AutoTextEditField lastName;

 private EmailAddressEditField email;
/*declaring choice field for user input*/
 private ObjectChoiceField gender;
 /*declaring check box field for user input*/
 private CheckboxField status;
 //Declaring button fields
 private ButtonField save;
 private ButtonField close;
 private ButtonField List;
 /*declaring vector*/
 private static Vector _data;
 /*declaring persistent object*/
 private static PersistentObject store;

 /*creating an entry point*/
public static void main(String[] args) 
{

  Display obj = new Display();
  obj.enterEventDispatcher();



}

/*creating default constructor*/
 public Display() 
 {

  /*Creating an object of the main screen class to use its functionalities*/
  MainScreen mainScreen = new MainScreen();

  //setting title of the main screen
  mainScreen.setTitle(new LabelField("Enter Your Data"));

  //creating text fields for user input
  firstName = new AutoTextEditField("First Name: ", "");
  lastName= new AutoTextEditField("Last Name: ", "");
  email= new EmailAddressEditField("Email:: ", "");

  //creating choice field for user input
  String [] items = {"Male","Female"};
  gender= new ObjectChoiceField("Gender",items);
  //creating Check box field
  status = new CheckboxField("Active",true);
  //creating Button fields and adding functionality using listeners
  save = new ButtonField("Save",ButtonField.CONSUME_CLICK);
  save.setChangeListener(new FieldChangeListener()
  {
   public void fieldChanged(Field field, int context)
   {
    save();

   }
  });
  close = new ButtonField("Close",ButtonField.CONSUME_CLICK);
  close.setChangeListener(new FieldChangeListener()
  {
   public void fieldChanged(Field field, int context)
   {
    onClose();
   }
  });
  List = new ButtonField("List",ButtonField.CONSUME_CLICK);
  List.setChangeListener(new FieldChangeListener()
  {
   public void fieldChanged(Field field, int context){

    pushScreen(new ListScreen());



   }
  });
  //adding the input fields to the main screen
  mainScreen.add(firstName);
  mainScreen.add(lastName);
  mainScreen.add(email);
  mainScreen.add(gender);
  mainScreen.add(status);
  //adding buttons to the main screen
  HorizontalFieldManager horizontal = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER);
  horizontal.add(close);
  horizontal.add(save);
  horizontal.add(List);
  mainScreen.add(horizontal);

  //adding menu items

  mainScreen.addMenuItem(saveItem);
  mainScreen.addMenuItem(getItem);
  mainScreen.addMenuItem(Deleteall);
  //pushing the main screen
  pushScreen(mainScreen);
 }
 private MenuItem Deleteall = new MenuItem("Delete all",110,10)
 {
  public void run()
  {
   int response = Dialog.ask(Dialog.D_YES_NO,"Are u sure u want to delete entire Database");
   if(Dialog.YES == response){
   PersistentStore.destroyPersistentObject(0xdec6a67096f833cL);
   onClose();
   }
   else
    Dialog.inform("Thank God");
  }
 };
//adding functionality to menu item "saveItem" 
private MenuItem saveItem = new MenuItem("Save", 110, 10) 
{

  public void run() 
  {
   //Calling save method
   save();
  }
};
//adding functionality to menu item "saveItem" 
private MenuItem getItem = new MenuItem("Get", 110, 11) 
{
 //running thread for this menu item
 public void run() 
 {


   //synchronizing thread
   synchronized (store) 
   {
    //getting contents of the persistent object

    _data = (Vector) store.getContents();
    try{

     for (int i = _data.size()-1; i >-1; i--) 
     {

      StoreInfo info = (StoreInfo)_data.elementAt(i);
      //checking for empty object
      if (!_data.isEmpty()) 
      {
      //if not empty
      //create a new object of Store Info class






      //storing information retrieved in strings
      getFirstName = (info.getElement(StoreInfo.NAME));
      getLastName  = (info.getElement(StoreInfo.LastNAME));
      getEmail   = (info.getElement(StoreInfo.EMail));
      getGender   =  (info.getElement(StoreInfo.GenDer));
      getStatus  = (info.getElement(StoreInfo.setStatus));

       //calling the show method
      show();
      }

     }
    }
    catch(Exception e){}
   } 
  }


};
public void save()
{



 //creating an object of inner class StoreInfo
 StoreInfo info = new StoreInfo();
 //getting the test entered in the input fields
 info.setElement(StoreInfo.NAME, firstName.getText());
 info.setElement(StoreInfo.LastNAME,lastName.getText());
 info.setElement(StoreInfo.EMail, email.getText());
 info.setElement(StoreInfo.GenDer,gender.toString());
 if(status.getChecked())
  info.setElement(StoreInfo.setStatus, "Active");
 else
  info.setElement(StoreInfo.setStatus, "In Active");
 //adding the object to the end of the vector
 _data.addElement(info);
 //synchronizing the thread
 synchronized (store) 
 {

  store.setContents(_data);
  store.commit();



 }
 //resetting the input fields

 Dialog.inform("Success!");
 firstName.setText(null);
 lastName.setText(null);
 email.setText("");
 gender.setSelectedIndex("Male");
 status.setChecked(true);


}
//coding for persistent store
static {

store =
PersistentStore.getPersistentObject(0xdec6a67096f833cL);
synchronized (store) {
if (store.getContents() == null) {
store.setContents(new Vector());
store.commit();
}
}
_data = new Vector();
_data = (Vector) store.getContents();

}
//new class store info implementing persistable
private static final class StoreInfo implements Persistable 
{
 //declaring variables
 private Vector _elements;
 public static final int NAME = 0;
 public static final int LastNAME = 1;
 public static final int EMail= 2;
 public static final int GenDer = 3;
 public static final int setStatus = 4;

 public StoreInfo() 
 {
  _elements = new Vector(5);
  for (int i = 0; i < _elements.capacity(); ++i) 
  {
   _elements.addElement(new String(""));
  }
 }

 public String getElement(int id) 
 {
  return (String) _elements.elementAt(id);
 }
 public void setElement(int id, String value) 
 {
  _elements.setElementAt(value, id);
 }
}
//details for show method
public void show()
{
 Dialog.alert("Name is "+getFirstName+" "+getLastName+"\nGender is "+getGender+"\nE-mail: "+getEmail+"\nStatus is "+getStatus);
}
public void list()
{

 Dialog.alert("haha");


}

//creating save method

//overriding onClose method

public boolean onClose()
{


 System.exit(0);
 return true;
}

 class ListScreen extends MainScreen 
{


  String firstUserName="Ali";
  String lastUserName="Asif";
  String userEmail="assad";
  String userGender="asdasd";
  String userStatus="active";
  private AutoTextEditField  userFirstName;
  private AutoTextEditField  userLastName;
  private EmailAddressEditField  userMail;
  private ObjectChoiceField  usersGender;
  private CheckboxField usersStatus; 
  private ButtonField btnBack;

 public ListScreen()
 {
  SeparatorField sps = new SeparatorField();
  HorizontalFieldManager hr = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER|HorizontalFieldManager.HORIZONTAL_SCROLLBAR);
  VerticalFieldManager vr = new VerticalFieldManager();
  setTitle(new LabelField("List of All Data"));
  list();
  btnBack = new ButtonField("Back",ButtonField.CONSUME_CLICK);
  btnBack.setChangeListener(new FieldChangeListener()
  {
   public void fieldChanged(Field field,int context)
   {
    UiApplication.getUiApplication().popScreen(getScreen());
   }
  });

  hr.add(btnBack);



  add(hr);
  add(sps);

 }
public void list()

 {
 _data = (Vector) store.getContents();
 try{
  int sn=0;
  for (int i = _data.size()-1; i >-1; i--,sn++) 
  {

   StoreInfo info = (StoreInfo)_data.elementAt(i);
   //checking for empty object
   if (!_data.isEmpty()) 
   {
   //if not empty
   //create a new object of Store Info class






   //storing information retrieved in strings
    firstUserName = (info.getElement(StoreInfo.NAME));
    lastUserName = (info.getElement(StoreInfo.LastNAME));
    userEmail  = (info.getElement(StoreInfo.EMail));
    userGender   =  (info.getElement(StoreInfo.GenDer));
    userStatus  = (info.getElement(StoreInfo.setStatus));

    //calling the listAll method
   listAll();
   }

  }
 }
 catch(Exception e){}

 }
 public void listAll()
 {
  SeparatorField sp = new SeparatorField();
  SeparatorField sps = new SeparatorField();
  HorizontalFieldManager hrs = new HorizontalFieldManager(HorizontalFieldManager.HORIZONTAL_SCROLL);
  hrs.add(new RichTextField(""+firstUserName+" "+lastUserName+" | "+userEmail+" | "+userGender+" | "+userStatus));
  //add(new RichTextField("Email: "+userEmail));
  //add(new RichTextField("Gender: "+userGender));
  //add(new RichTextField("Status: "+userStatus));
  //SeparatorField sp = new SeparatorField();
  add(hrs);
  add(sp);
  add(sps);
 }

 public boolean onClose()
 {
  System.exit(0);
  return true;
 }

}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:19:26+00:00Added an answer on May 12, 2026 at 6:19 pm

    There is a nice GridFieldManager by Anthony Rizk.

    Code:

        public void list()
        {
            if (null != mGrid && null != mGrid.getManager())
                mGrid.getManager().delete(mGrid);
            int colWidth = net.rim.device.api.system.Display.getWidth() / 4; 
            mGrid = new GridFieldManager(new int[] { 0, colWidth, colWidth,
                    colWidth, colWidth }, VERTICAL_SCROLL | VERTICAL_SCROLLBAR);
            mGrid.add(new NullField(FOCUSABLE));
            mGrid.add(new LabelField("Name"));
            mGrid.add(new LabelField("E-Mail"));
            mGrid.add(new LabelField("Gender"));
            mGrid.add(new LabelField("Active"));
            add(mGrid);
            _data = (Vector) store.getContents();
            try {
                int sn = 0;
                for (int i = _data.size() - 1; i > -1; i--, sn++) {
    
                    StoreInfo info = (StoreInfo) _data.elementAt(i);
                    // checking for empty object
                    if (!_data.isEmpty()) {
                        // if not empty
                        // create a new object of Store Info class
    
                        // storing information retrieved in strings
                        firstUserName = (info.getElement(StoreInfo.NAME));
                        lastUserName = (info.getElement(StoreInfo.LastNAME));
                        userEmail = (info.getElement(StoreInfo.EMail));
                        userGender = (info.getElement(StoreInfo.GenDer));
                        userStatus = (info.getElement(StoreInfo.setStatus));
    
                        // calling the listAll method
                        mGrid.add(new NullField(FOCUSABLE));
                        mGrid.add(new LabelField(firstUserName + " "
                                + lastUserName));
                        mGrid.add(new LabelField(userEmail));
                        mGrid.add(new LabelField(userGender));
                        mGrid.add(new LabelField(userStatus));
                    }
    
                }
            } catch (Exception e) {
            }
    
        }
    

    See also
    BlackBerry Grid Layout Manager updated

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add a custom table to my iPhone app, that should look
I really need help with filling in data in a Table View, where my
My app has two tabs, one of which is a table view, in the
Here is the scenario: I'm writing an app that will watch for any changes
Here's the scenario. I'm debugging my own app (C/C++) which is using some library
In my JSF/Facelets app, here's a simplified version of part of my form: <h:form
I have a Rails app that I need to deploy. Here are the facts:
Ok, here's one for the JavaScript gurus: In my app, one of the controllers
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
I have a view based app that works well. (In other words, I'm not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.