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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:03:14+00:00 2026-06-01T08:03:14+00:00

I have 2 activities. The first activity is an activity that parses JSON data

  • 0

I have 2 activities.

The first activity is an activity that parses JSON data from a server to a ListView and the second activity is an activity that displays the data from selected values in the ListView.

Here’s the onClick method of my 1st activity :

/**
     * Updating parsed JSON data into ListView
     * */
    ListAdapter adapter = new SimpleAdapter(this, userList,
            R.layout.listitemviewall,
            new String[] { "namaresto", "alamatresto"}, 
            new int[] {R.id.name, R.id.address});

    setListAdapter(adapter);

    /**
     * select resto
     */

final ListView lv = getListView();
    lv.setTextFilterEnabled(true);  
    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {              

            /** 
             * move to the next activity 
             * */

            String namanya = ((TextView) findViewById(R.id.name)).getText().toString();
            String alamatnya = ((TextView) findViewById(R.id.address)).getText().toString();

            //Starting a new Intent
            Intent nextScreen = new Intent(getApplicationContext(), InfoTab.class);

            //Sending data to another Activity
            nextScreen.putExtra("name", namanya);
            nextScreen.putExtra("address", alamatnya);

            // starting new activity
            startActivity(nextScreen);


         }
    });

And here is the second activity :

TextView txtname = (TextView) findViewById(R.id.textTEST1);
TextView txtaddress = (TextView) findViewById(R.id.TextTEST2);



    //displaying data from previous activity
    Intent i = getIntent();
    // Receiving the Data
    String name = i.getStringExtra("name");
    String address = i.getStringExtra("address");

    // Displaying Received data
    txtname.setText(name);
    txtaddress.setText(address);

The Result, the second Activity always displays THE FIRST RECORD! Even if i clicked the second or other record in the ListView.

How can i get my code to display the correct record that is selected in the ListView?

  • 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-01T08:03:14+00:00Added an answer on June 1, 2026 at 8:03 am

    try changing these lines:

       String namanya = ((TextView) findViewById(R.id.name)).getText().toString();
            String alamatnya = ((TextView) findViewById(R.id.address)).getText().toString();
    

    to:

        String namanya = ((TextView) view.findViewById(R.id.name)).getText().toString();
            String alamatnya = ((TextView)  view.findViewById(R.id.address)).getText().toString();
    

    tell me if that works for you…

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

Sidebar

Related Questions

I have two activities. In first I come to the second activity from first
I have total 3 activities. First activity(A) starts second activity(B). From Activity B, 3rd
I have 3 Activities...the first Activity have a button that start third Activity. The
I have an activity group which contains 2 activities. From first activity I goto
I have two activities or screens. The second activity has an AlertDialogBox with radiobuttons
I have an app that goes between many different activities. One activity, my main
I have two activities and the first is generating properly however the second is
What Is Working Fine I have 2 activities in my app. First activity calls
Here's scenario: I have 2 activities and one service First activity is a landing
I have following goal: From a list in main activity that extends ListActivity, I

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.