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 6077855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:46:03+00:00 2026-05-23T10:46:03+00:00

Plz give the code or function how to clear the ListField and update the

  • 0

Plz give the code or function how to clear the ListField and update the ListField .
Suppose i want to display some multiple text( Project Name, Project Manager )extracted from JSON object , in a ListField.
I am able to display this strings in the ListField but one more feature i need to add ie.. above the ListField there should be a ButtonField and when the user clicks on the ButtonField the ListField should display the string in sorted manner base on Project Name. So i need to clear the ListField

Code for NetworkingMainScreen is

package src1;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.system.*;

import org.json.me.JSONArray;
import org.json.me.JSONException;
import org.json.me.JSONObject;
import java.util.Vector;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.UiApplication;






class NetworkingMainScreen extends MainScreen
{


     private EditField urlField;
     private BitmapField imageOutputField;
     private RichTextField textOutputField;

     private ListField prjctlist_Field;
     private Vector prjct_list_v = new Vector();
     VerticalFieldManager vfm;

     private String prjts;
    public int total_prjcts;
    JSONArray data_json_array;
    JSONObject outer;
    ListField myList;
    private Vector v_prj_title;
    private Vector v_prj_mgr;
    private Vector send_vector;
    private Vector send_vector3;
    private Vector send_vector4;
    private String t1,t2;
    public JSONArray jsArrPrjts;
    ListCallBack callback;
    ButtonField sort;


    NetworkingMainScreen() 
    {


       // Screen2 s = new Screen2();
       // UiApplication.getUiApplication.pushScreen(s);


        setTitle("Networking");
        urlField = new EditField("URL:", "http://iphone.openmetrics.com/apps/mattson/api.html?action=login&user=Nathan&password=coffee00&server=exp.lcgpence.com;deviceside=true");
        textOutputField = new RichTextField();
        imageOutputField = new BitmapField();


        add(urlField);

        add(new SeparatorField());


        add(new LabelField("Text retrieved:"));
        add(textOutputField); 

        myList = new ListField();
        callback = new ListCallBack();
        myList.setRowHeight(80);
        myList.setCallback(callback);

        add(myList);






    }

    protected void makeMenu(Menu menu, int instance) 
    {
    super.makeMenu(menu, instance);
    menu.add(new MenuItem("Get", 10, 10) {
    public void run() {
    getURL();
    }
    });
    }

    private void getURL()
    {
        HttpRequestDispatcher dispatcher = new HttpRequestDispatcher(urlField.getText(),"GET", this);
        dispatcher.start();
    }


    public void requestSucceeded(byte[] result, String contentType) 
    {

          if (contentType.startsWith("text/")) {
           synchronized (UiApplication.getEventLock()) 
          {     
          String strResult = new String(result);
          try
          {
            JSONObject joPrjt = new JSONObject(strResult);
            String res_code = joPrjt.optString("responseCode");

            if( res_code.equals("1"))
            {


               data_json_array = new JSONArray();
               data_json_array = joPrjt.optJSONArray("data");

               int s = data_json_array.length();
               v_prj_title = new Vector();
               v_prj_mgr = new Vector();
               outer = new JSONObject();
               for(int i=0; i<s; i++)
               {
                 //outer = new JSONObject();
                 outer = data_json_array.getJSONObject(i);

                String job_no = outer.optString("job_number");
                String contract_date = outer.optString("contract_date");
                String project_title = outer.optString("project_title");
                String project_manager = outer.optString("project_manager");
                String created_date = outer.optString("created_date");
                String project_name = outer.optString("project_name");
                v_prj_title.addElement(project_title);
                v_prj_mgr.addElement(project_manager);
              }
               UiApplication.getUiApplication().pushScreen(new Screen2(v_prj_title,v_prj_mgr,0,v_prj_title,v_prj_mgr));


            }
            else
            {
                Dialog.alert("Web page connected but not the requested page");
            }

          }
          catch(JSONException e)
          {
             e.printStackTrace();
             System.out.println("key not found catched " + e);   
          }
        }


          }
          else 
          {
    synchronized (UiApplication.getEventLock()) {
    Dialog.alert("Unknown content type: " + contentType);
     }
     }

      }



      public void requestFailed(final String message) 
      {
          UiApplication.getUiApplication().invokeLater(new Runnable() {
     public void run() {
    Dialog.alert("Request failed. Reason: " + message);
    }  
    });

      }




     } 

Code for Screen2 is

   package src1;

   import net.rim.device.api.ui.container.MainScreen;

   import net.rim.device.api.ui.component.ButtonField;

   import net.rim.device.api.ui.component.LabelField;

   import org.json.me.JSONArray;

  import org.json.me.JSONException;

   import org.json.me.JSONObject;

  import java.util.Vector;

  import net.rim.device.api.ui.container.VerticalFieldManager;

import net.rim.device.api.ui.component.ButtonField;

import net.rim.device.api.ui.FieldChangeListener;

import net.rim.device.api.ui.component.ListField;

import net.rim.device.api.ui.Field;

import net.rim.device.api.ui.UiApplication;



class Screen2 extends MainScreen implements FieldChangeListener

{

    JSONArray j_array;

    JSONObject j_object;

    CustomButtonField bf1;


    Vector v_prj_title,v_prj_mgr,v_job_no,v_created_date,v_prj_name,send_vector;

    Vector main_v_prj_title,main_v_prj_mgr;

    String job_no,contract_date,project_title,project_manager,created_date,project_name;

    VerticalFieldManager vfm;

    ListField myList;

    ListCallBack callback;

    int pic_status;

    int b;

    String t1,t2;



    String temp1,temp2,f1,f2;

   // ListField prjctlist_Field;

    Screen2(Vector v_prj_title2,Vector v_prj_mgr2,int pic_status,Vector main_v_prj_title_o2,Vector main_v_prj_mgr_o2) 

    {    


            this.main_v_prj_title = main_v_prj_title_o2;
            this.main_v_prj_mgr = main_v_prj_mgr_o2;

        this.v_prj_title = v_prj_title2;
        this.v_prj_mgr = v_prj_mgr2;

        this.pic_status = pic_status;

        bf1 = new CustomButtonField("Name",pic_status,0); 
        bf1.setChangeListener(this);
        vfm = new VerticalFieldManager();
        vfm.add(bf1);
        int s = v_prj_title.size();
        myList = new ListField();
        callback = new ListCallBack();
        myList.setRowHeight(80);
        myList.setCallback(callback);
        for(int i=0;i<s;i++)
           {
               myList.insert(i);
               t1 = v_prj_title.elementAt(i).toString();
               send_vector = new Vector(2);
               send_vector.addElement(t1);
               t2 = v_prj_mgr.elementAt(i).toString();
               send_vector.addElement(t2);
               callback.insert(send_vector,i);
           }
        vfm.add(myList);
        add(vfm);
    }


    public void fieldChanged(Field field, int context) 
    {
        if(field == bf1)
        {

          if(pic_status == 0)
           {
               b =1;
               int s = v_prj_title.size();

               for(int i=0;i<s;i++)
               {
                   for(int t=i+1;t<s;t++)
                   {
                        temp1 = (String)v_prj_title.elementAt(i);


                        temp2 = (String)v_prj_title.elementAt(t);

                         if(temp1.compareTo(temp2)>0)
                         {
                             //System.out.println("Comparision Executed :"+temp1 + " is greater than " + temp2);
                             f1 = (String)v_prj_mgr.elementAt(i);
                             f2 = (String)v_prj_mgr.elementAt(t);
                             v_prj_title.setElementAt(temp1,t);
                             v_prj_title.setElementAt(temp2,i);

                              v_prj_mgr.setElementAt(f1,t);
                              v_prj_mgr.setElementAt(f2,i);


                          }
                    }

              }

               UiApplication.getUiApplication().pushScreen(new Screen2(main_v_prj_title,main_v_prj_mgr,b,main_v_prj_title,main_v_prj_mgr));
           }     

          if(pic_status == 1)
          {
          b=0;
          UiApplication.getUiApplication().pushScreen(new Screen2(main_v_prj_title,main_v_prj_mgr,b,main_v_prj_title,main_v_prj_mgr));

          }




        }


      }

     } 

one more thing i need to clearify is that in my above code firstly i have parsed the JSON object in NetworkingMainScreen and if the JSON parsing is success i have push a new screen name Screen2 passing the stored Vector to the Screen2. The Screen2 performs ListField drawings or should i perform the ListField drawing in NetworkingMainScreen class only.

 For details about the items i need to display plz look **http://iphone.openmetrics.com/apps/mattson/api.html?action=login&user=Nathan&password=coffee00&server=exp.lcgpence.com&output=data**
  • 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-23T10:46:03+00:00Added an answer on May 23, 2026 at 10:46 am

    Implement ListFieldCallback in your screen, you can then handle the drawing of your rows however you want in drawListRow.

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

Sidebar

Related Questions

hello everyone i have multiple dynamic edittext box.i want to give width to fill
Suppose i have an animated GIF image name test.GIF added to my project in
I want to render a <label> tag. But want to set some of it's
hi currently i have developed my own website named www.eyeview.com. i want to update
i want to hide and show my text box according to drop down select
I'm building a tiny webapplication in which our customers can update some details about
I want to create an application that can give me a description of all
Cold you plz look the following code, <table title=Demo1> <tr> <td> <a href= id=anch1>Test1</a>
plz guide me how I can enable or disable asp.net validation controls using jQuery
am getting this error when i open my site in internet explorer......... plz help

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.