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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:27:45+00:00 2026-06-13T12:27:45+00:00

Can any one help me..?? My problem is that, after getting response from json

  • 0

Can any one help me..?? My problem is that, after getting response from json [its coming from webservice, in that there is Select query to fetch records], instead of display in listview its go back to previous screen Here is my sample code for that..

public class MainActivity5 extends ListActivity {

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.custom_list_view);

        Intent i = getIntent();
        phNumber = i.getStringExtra("phn_no");

        new SearchCustomer().execute();

        ListAdapter adapter = new SimpleAdapter(this, customerList, R.layout.activity_main5, new String[] { TAG_F_NAME, TAG_C_PHONE }, new int[] { R.id.TextViewName, R.id.TextViewPhone });
        setListAdapter(adapter);

    }

    class SearchCustomer extends AsyncTask<String, String, String> {

        private boolean successFlag;

        @Override
        protected void onPreExecute() {

            super.onPreExecute();
            pDialog = new ProgressDialog(MainActivity5.this);
            pDialog.setMessage("Searching Customer..");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(true);
            pDialog.show();
        }

        protected String doInBackground(String... args) {

            String inputPhnNoText = phNumber;

            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("phno", inputPhnNoText));
            JSONObject json = jsonParser.makeHttpRequest(url_search_customer, "POST", params);
            Log.d("Search Response", json.toString());

            try {
                int success = json.getInt(TAG_SUCCESS);
                if (success == 1) {
                    successFlag = true;
                    result = json.getJSONArray(TAG_RESULT);
                    for (int i = 0; i < result.length(); i++) {
                        JSONObject c = result.getJSONObject(i);
                        String id = c.getString(TAG_ID);
                        String fname = c.getString(TAG_F_NAME);
                        String phoneNumber = c.getString(TAG_C_PHONE);

                        // creating new HashMap
                        HashMap<String, String> map = new HashMap<String, String>();

                        // adding each child node to HashMap key => value
                        map.put(TAG_ID, id);
                        map.put(TAG_F_NAME, fname);
                        map.put(TAG_C_PHONE, phoneNumber);
                        // adding HashList to ArrayList
                        customerList.add(map);
                    }
                }
                else {
                    successFlag = false;
                }
            }
            catch (JSONException e) {
                Log.e("log_tag", "Error parsing data " + e.toString());
            }
            return null;
        }

        protected void onPostExecute(String file_url) {

            pDialog.dismiss();
            finish();
        }
    }
}

This is my activity file code.. in doinbackground customerList I got the exact data what I want, but problem is that its not stay in the custom_list_view screen its go back to previous screen where a textbox and search button are there.. so not able to show record…

Everybody please, can any one give solution to this silly thing?

  • 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-06-13T12:27:46+00:00Added an answer on June 13, 2026 at 12:27 pm
    1. Agree with CapDroid regarding finish(), don’t do it.

    2. Don’t call create adapter and set adapter inside onCreate(), instead you can do it inside onPostExecute().

    3. You are doing 2 overheads, Don’t do those.

    For example:

     for (int i = 0; i < result.length(); i++) {
                            JSONObject c = result.getJSONObject(i);
                            String id = c.getString(TAG_ID);
                            String fname = c.getString(TAG_F_NAME);
                            String phoneNumber = c.getString(TAG_C_PHONE);
    
                            // creating new HashMap
                            HashMap<String, String> map = new HashMap<String, String>();
    
                            // adding each child node to HashMap key => value
                            map.put(TAG_ID, id);
                            map.put(TAG_F_NAME, fname);
                            map.put(TAG_C_PHONE, phoneNumber);
                            // adding HashList to ArrayList
                            customerList.add(map);
                        }
    

    No need to do this kind of overhead, instead you can create a custom adapter by extending ArrayAdapter<JSONObject> so you don’t need to prepare HashMap, instead you can add JSONObject directly.

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

Sidebar

Related Questions

can any one help me with code that subtract 1 from a digit stored
i am getting problem with this can any one help me here is my
Can any one help in transforming my xml though XSLT. I am new to
Can any one help me, i already checked resizing demo but this work through
can any one help me in creating a regular expression for password validation. The
Can any one help me how to sort rows by relevance for the following
I want to close a tab after getting confirmation from user. It can be
After getting good help previously, I have completed my Minesweeper game. However, there is
Can anyone help with an odd Ruby Gem problem I'm having - note I've
Can anyone help me spot the problem on this PLEASE? I'm eternally grateful for

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.