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

  • Home
  • SEARCH
  • 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 6967385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:18:52+00:00 2026-05-27T16:18:52+00:00

I used a static list and checked the value selected, and it was correct.

  • 0

I used a static list and checked the value selected, and it was correct. Now applying the same code to a list which is dynamically populated from SQLite db is showing a junk value for the value clicked. Here is the code

class mal2eng extends MainScreen
                            implements ListFieldCallback {


    private ListField _listfield;


    private Item _selected = null; 



    private Vector _listVector = new Vector();



    mal2eng() {

        Database d;
        try
                {
                    URI myURI=URI.create("file:///SDCard/Databases/MyTestDatabase.db");
                    d=DatabaseFactory.open(myURI);
                   Statement st=d.createStatement("SELECT malLetter FROM MalayalamLetter");
                   st.prepare();
                   net.rim.device.api.database.Cursor c=st.getCursor();
                   Row r;

                   while(c.next())
                   {

                    r=c.getRow();
                    String w=r.getString(0);

                    _listVector.addElement(new Item(w));
                   }
                   st.close();
                   d.close();
                   }
                     catch ( Exception e ) 
        {         
            System.out.println( e.getMessage() );
            e.printStackTrace();
        }                      


        this.setTitle("List");


        _listfield = new ListField(_listVector.size());
        _listfield.setCallback(this); 
             FontManager.getInstance().load("DC124.TTF", "MyFont", FontManager.APPLICATION_FONT) ;
        {
             try {
                FontFamily typeface = FontFamily.forName("MyFont");
                Font myFont = typeface.getFont(Font.PLAIN, 25);
                _listfield.setFont(myFont);
                this.add(_listfield);
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();}

            }



    }

    protected boolean onSavePrompt() {
        return true;
    }

    protected void makeMenu( Menu menu, int instance ) {

    }

    public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
        Item ToDraw = (Item) this.get(list, index);
        int drawColor = Color.BLACK;

        g.setColor(drawColor);
        g.drawText(ToDraw.word, 0, y, 0, w);
    }


    public Object get(ListField list, int index) {

         return _listVector.elementAt(index);
    }

    public int getPreferredWidth(ListField list) {
        return Display.getWidth();
    }

    public int indexOfList(ListField listField, String prefix, int start) {

        return start;
    }

    public boolean navigationClick(int status, int time) {
    Field focus = _listfield.getLeafFieldWithFocus();


    if (focus instanceof ListField) {
        ListField listField = (ListField)focus;
       String w=listField.getCallback().get(listField,listField.getSelectedIndex()).toString();
      UiApplication ui = UiApplication.getUiApplication();
      ui.pushScreen(new ListFieldScreen(w));
    }
    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-27T16:18:53+00:00Added an answer on May 27, 2026 at 4:18 pm

    A small thing you can do as you are getting the Data from database use a dataStructure like Vector or something of that kind . Put the data in the vector which you are getting from the database.override the navigationClick method like below …

    navigationClickMethod(int, int ){
     //Call getSelectedindex here 
    
     // And use this to call Element at the selected index of the dataStructure you have 
    
    }
    

    this is the simplest way to get the selected values from the list …

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

Sidebar

Related Questions

I have a number of static List's in my application, which are used to
I've seen a few implementations of popen()/pclose(). They all used a static list of
Consider the following code: class Program { static Program() { Program.program1.Value = 5; }
I have used a static global variable and a static volatile variable in file
I am used to having static methods in the App_Code folder, this folder is
When used like this: import static com.showboy.Myclass; public class Anotherclass{} what's the difference between
1) Static class members can be used to separate data and behavior that is
I used in my C++/CLI project static array's like: static array < array< String^>^>^
I've read that static variables are used inside function when one doesn't want the
I used the command line arp -s IP MAC command to set a static

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.