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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:10:14+00:00 2026-06-09T23:10:14+00:00

I am developing an application the returns data from a MYSQL database and displays

  • 0

I am developing an application the returns data from a MYSQL database and displays the results in a listview. This consists of a Name, Address and a Number. When an item in the listview is selected i want it to open another page that displays the details of the item list you clicked on. How would I go about this?I know I will have to use the onListItemClick method but how can I create a page template that will be loaded with the information from whatever item in the list you clicked on? Thanks

Here is the code I use to connect to the database and query it and then display the results in a listview:

public class HttpExample extends ListActivity {

TextView httpStuff;
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    // setContentView(R.layout.httpex);
    setContentView(R.layout.listplaceholder);
    httpStuff = (TextView) findViewById(R.id.tvHttp);

    GetMethodEx test = new GetMethodEx();
    String returned;
    try {
        returned = test.getInternetData();
        httpStuff.setText(returned);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    ListAdapter adapter = new SimpleAdapter(this, mylist, R.layout.main,
            new String[] { "name", "address", "number" }, new int[] {
                    R.id.item_title, R.id.item_subtitle, R.id.item_number });

    setListAdapter(adapter);

}

public class GetMethodEx {

    public String getInternetData() throws Exception {

        BufferedReader in = null;
        String data = "";
        String returnString = "";

        // httpGet

        try {

            HttpClient client = new DefaultHttpClient();
            URI website = new URI("http://192.168.0.10/connect.php");
            HttpGet request = new HttpGet();
            request.setURI(website);
            HttpResponse response = client.execute(request);
            in = new BufferedReader(new InputStreamReader(response
                    .getEntity().getContent()));
            StringBuffer sb = new StringBuffer("");
            String l = "";
            String nl = System.getProperty("line.separator");

            while ((l = in.readLine()) != null) {
                sb.append(l + nl);
            }
            in.close();
            data = sb.toString();
            // return data;
        } catch (Exception e) {
            Log.e("log_tag", "Error converting result " + e.toString());
        }
        // parse json data
        try {
            JSONArray jArray = new JSONArray(data);
            for (int i = 0; i < jArray.length(); i++) {
                HashMap<String, String> map = new HashMap<String, String>();
                JSONObject json_data = jArray.getJSONObject(i);

                map.put("id", String.valueOf(i));
                map.put("name",
                        "ShopName:" + json_data.getString("shopname"));
                map.put("address",
                        "Address: " + json_data.getString("address"));
                map.put("number", "Number: " + json_data.getInt("number"));
                mylist.add(map);

            }
        } catch (JSONException e) {
            Log.e("log_tag", "Error parsing data " + e.toString());
        }
        return returnString;

    }

}

}
  • 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-09T23:10:15+00:00Added an answer on June 9, 2026 at 11:10 pm

    What you want to do is pass data via Intents.

    From the onListItemClick method, have the following code:

    Intent intent = new Intent(getContext(), NewActivity.class);
    intent.putExtra("NAME", name);
    intent.putExtra("ADDRESS", address);
    // etc
    
    startActivity(intent)
    

    Then, in the new Activity’s onCreate() method, do the following:

    Intent intent = getIntent();
    String name = intent.getStringExtra("NAME");
    // ...etc
    

    For further info, there’s a lesson on this in the Android Training site, called Starting Another Activity

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

Sidebar

Related Questions

I have developing the application to fetching data from sd card. I used this
I am developing an iPhone application that GETS data from my ASP.NET web service
We are developing a standalone application that stores its data in a Database. We
I'm looking into developing an application that will process data from a line-scan camera
I'am developing an iPhone application to display data from php. Data are obtained from
I am developing an application in which i am displaying data from back-end. Now
I'm developing simple Windows Service sending and receiving data from remote web service. I
We're developing a layered web application. The specs: 3 layers, data layer, business layer,
I am developing an application with PyQT4 which will POST some data to a
I am developing a web application where i have database backend with geo located

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.