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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:44:00+00:00 2026-05-26T14:44:00+00:00

I created one simple list view. i have two list view, my 1st list

  • 0

I created one simple list view. i have two list view, my 1st list view display only one item that item name is fruit. if i click fruit in list view it will go to 2nd list view. 2nd list view display many number of fruits name. if i select one fruit i want show that fruit name in my 1st list view(i want bind that fruit name in my 1st list view) so, i am using onitemselectedlistener but it’s not working. if i click my 2nd list view fruit name nothing happend….please check my source code and help me….

1st list view:

     public class bview extends ListActivity {    

 /** Called when the activity is first created. */    

     @Override     

    public void onCreate(Bundle savedInstanceState) {         
    super.onCreate(savedInstanceState);         

    setListAdapter(new ArrayAdapter(this,android.R.layout.simple_list_item_1, cat));         getListView().setTextFilterEnabled(true);     }      
    static final String[] cat = new String[] {         "Category", }; 

    protected void onListItemClick(ListView parent, View v, int position,long id) {                        
    Intent intent= new Intent(bview.this,listview.class);             
    startActivity(intent);             
    //intent.putExtra("value", value);                              }} 

2nd list view:

public class listview extends Activity
{    


    @Override    
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.submain);


        ListView mlistView = (ListView) findViewById(R.id.listview);
        mlistView.setAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, 
                new String[] {"orange", "apple","mango","banana","grapes"}));

 mlistView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
     public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,long arg3){
         Intent in2 =new Intent(listview.this, bview.class);
         startActivity(in2);
     }
public void onNothingSelected(AdapterView<?>arg0){
 }});

}}
  • 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-26T14:44:01+00:00Added an answer on May 26, 2026 at 2:44 pm

    Your problem is that your not passing what was selected in the second list back to the first list. You need to include what was selected in your intent and then in your first activity you need to check if that was included in the Intent it was started with. So you’d so something like this.

    In your second activity:

    mlistView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
      public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,long arg3){
         Intent in2 =new Intent(listview.this, bview.class);
         in2.putExtra("SELECTED_ITEM", (String)arg0.getItemAtPosition(arg2));
         startActivity(in2);
      }
      public void onNothingSelected(AdapterView<?>arg0){
    }});
    

    In your first activity you’ll need to add this code in your onCreate method:

    Intent givenIntent = getIntent();
    if(givenIntent.hasExtra("SELECTED_ITEM")){
      String selectedItem = givenIntent.getStringExtra("SELECTED_ITEM");
      //now do what ever you want with the face that you have the item that was selected
    }
    else{
      //in here you know the activity was started by selecting something from your second
      //activity. so do what you need to do in that case here.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a bit confused. I have created a simple form with a one
I have created one aspx Page from that i need to access the property
In My application i am using two list view's in one activity, one for
I've created a miniature 'web server' that simply returns one message to any request
Let's say that you want to create a dead simple BlogEditor and, one of
I created one GWT webapplication project.Inthat i want to create servlet program,but in that
I have created one table using the below command: create table Table1( Id int
I'm learning Rails by writing simple TODO tasks aplication. Two models are: class List
I have a grouped tableview that is populated with XML data in one section.
hi I created one simple xml based spinner application.i got all value in my

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.