1. Download our Official Android App: Forums for Android!

Apps how to show another List View

Discussion in 'Android Development' started by soclose, Apr 4, 2010.

  1. soclose

    soclose Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Apr 4, 2010

    Apr 4, 2010
    2
    0
    5
    Hi

    I'd like to show another List View 'B' after clicking a item of List View 'A'. I use onListItemClick event in Android 1.6 project.

    Code (Text):
    1. public void onListItemClick(
    2.             ListView parent, View v,
    3.             int position, long id)
    4.             {  
    5.                 Toast.makeText(this,
    6.                     "You have selected " + lv_arr[position],
    7.                     Toast.LENGTH_SHORT).show();
    8.             }  
    how to code it? :thinking:
     

    Advertisement

  2. jon21569

    jon21569 Newbie
    Rank:
    None
    Points:
    16
    Posts:
    23
    Joined:
    Aug 10, 2008

    Aug 10, 2008
    23
    7
    16
    You can launch a new activity and show the new list there.

    public void onListItemClick( ListView parent, View v, int position, long id)
    {
    final Intent i = new Intent(this, NewListActivity.class);
    startActivity(i);
    }
     
  3. soclose

    soclose Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Apr 4, 2010

    Apr 4, 2010
    2
    0
    5
    I got 'Source not found' error.

    Code (Text):
    1.  
    2. public void onListItemClick(
    3.             ListView parent, View v,
    4.             int position, long id)
    5.             {  
    6.                 final Intent i = new Intent(this, WLView.class);
    7.                 startActivity(i);
    8.             }
    9.  
    how to solve?:(
     

Share This Page

Loading...