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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:29:42+00:00 2026-06-08T17:29:42+00:00

I have an app which reads some data from JSON, and I have 2

  • 0

I have an app which reads some data from JSON, and I have 2 classes which do this.

Right now both classes display the full list of registered members.
But what I’m trying to achieve is that when a member is clicked I only get to see that member and not the other ones as well.

Here is the code from both classes:

From the listview:

public class Listviewer extends ListActivity {
    
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);


        setContentView(R.layout.listplaceholder);

       
        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
      
       
        JSONObject json = JSONfunctions.getJSONfromURL("http://de-saksen.nl/deelnemers.txt");
                
        try{
            
            JSONArray  deelnemers = json.getJSONArray("deelnemers");
            
            for(int i=0;i<deelnemers.length();i++){                     
                HashMap<String, String> map = new HashMap<String, String>();    
                JSONObject e = deelnemers.getJSONObject(i);
                
                map.put("id",  String.valueOf(i));
                map.put("name", "Character Naam: " +  e.getString("naamingw2"));
                map.put("sex", "Geslacht: " +  e.getString("geslacht"));
                map.put("rank", "Rang: " +  e.getString("rang"));

                mylist.add(map);            
            }   
               
            
            
        }catch(JSONException e)        {
             Log.e("log_tag", "Error parsing data "+e.toString());
        }
        
        ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.main, 
                        new String[] { "name", "sex", "rank"}, 
                        new int[] { R.id.item_title, R.id.item_subtitle, R.id.item_subtitle2 });
        
        setListAdapter(adapter);
        
        final ListView lv = getListView();
        lv.setTextFilterEnabled(true);  
        lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {              
                Intent intent = new Intent(Listviewer.this, Profileviewer.class);   
                startActivity(intent); 
            }
        });

    
    
    }
}

And from the profile view:

public class Profileviewer extends ListActivity {
    
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);

        setContentView(R.layout.listplaceholder);
       
        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
       
        JSONObject json = JSONfunctions.getJSONfromURL("http://de-saksen.nl/deelnemers.txt");
                
        try{
            
            JSONArray  deelnemers = json.getJSONArray("deelnemers");
            
            for(int i=0;i<deelnemers.length();i++){                     
                HashMap<String, String> map = new HashMap<String, String>();    
                JSONObject e = deelnemers.getJSONObject(i);
                
                map.put("id",  String.valueOf(i));
                map.put("name", "Naam: " +  e.getString("naamingw2"));
                map.put("sex", "Geslacht: " +  e.getString("geslacht"));
                map.put("rank", "Rang: " +  e.getString("rang"));
                map.put("race", "Ras: " +  e.getString("ras"));
                map.put("profession", "Beroep: " +  e.getString("beroep"));
                map.put("skills", "Hobby's: " +  e.getString("hobbys"));
                map.put("lvl", "Level: " +  e.getString("level"));
                mylist.add(map);            
            }   
               
            
            
        }catch(JSONException e)        {
             Log.e("log_tag", "Error parsing data "+e.toString());
        }
        
        ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.profile, 
                        new String[] { "name", "sex", "rank", "race", "profession", "skills", "lvl" }, 
                        new int[] { R.id.item_title, R.id.item_subtitle, R.id.item_subtitle2, R.id.item_subtitle3, R.id.item_subtitle4, R.id.item_subtitle5, R.id.item_subtitle6 });
        
        setListAdapter(adapter);
        
        final ListView lv = getListView();
        lv.setTextFilterEnabled(true);  
        lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {              
                Intent intent = new Intent(Profileviewer.this, Listviewer.class);   
                startActivity(intent); 
            }
        });

    
    
    }
}

I recon I have to pass a variable to the other class containing what member has been clicked, but how do I achieve this?

  • 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-08T17:29:43+00:00Added an answer on June 8, 2026 at 5:29 pm

    using the intent:

    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {              
            Intent intent = new Intent(Profileviewer.this, Listviewer.class);
            intent.putExtra("Key", value);
            startActivity(intent); 
        }
    });
    

    Then in Listviewer.java:

    getIntent().getStringExtra("Key"); //for example
    

    To pass user data, modify like:

    String [] users = new String[] { "name", "sex", "rank", "race", "profession", "skills", "lvl" };
    int[] ids = new int[] { R.id.item_title, R.id.item_subtitle, R.id.item_subtitle2, R.id.item_subtitle3, R.id.item_subtitle4, R.id.item_subtitle5, R.id.item_subtitle6 };
    
    ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.profile, 
                    users, ids);
    
    setListAdapter(adapter);
    
    final ListView lv = getListView();
    lv.setTextFilterEnabled(true);  
    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {              
            Intent intent = new Intent(Profileviewer.this, Listviewer.class);   
            intent.putExtra("Key", users[position]);
            startActivity(intent); 
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function in an iOS app which reads in some data from
I have an iOS app which gets some JSON from a server (in the
I have a SL application that reads some data from the database, which I
I have an App which receives a SQLite database to read some data and
Pretty straightforward question. I'm building an app which reads data from a SQL Server
I just copied some code from an asp.net mvc 2 app which works. Now
I have created a library which reads the app.config file and gets the type
I have a app which will download a file from web. The download action
I have an app which has a map and some POI on it. I'm
I have an app which contain some images in res/drawable/ and shows them in

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.