Listview Help!

This is a discussion on Listview Help! within the Beginning Developers forums, part of the Android Development category; Hi everyone. Let's say that I have two buttons (buttonA and buttonB) on the screen. When the user clicks buttonA I would like for a ...

Results 1 to 2 of 2

Thread: Listview Help!

  1. #1
    Android Lurker skewedToTheLeft's Avatar
    Join Date
    May 2012
    Posts
    1

    Listview Help!

    Hi everyone. Let's say that I have two buttons (buttonA and buttonB) on the screen. When the user clicks buttonA I would like for a list of items to appear in the listview object. Likewise, when the user clicks buttonB I would like for the same listview object to populate a different list. How do I accomplish this?

    Thanks

  2. Android.net is the premier Android Forum. Registered users do not see these ads. .

  3. #2
    Android Lurker Piotr's Avatar
    Join Date
    May 2012
    Posts
    1
    You can write two classes extending ArrayAdapter<> (also you can use standard)


    Code:
    class adapterA extends ArrayAdapter{...}

    and


    Code:
    class adapterB extends ArrayAdapter{...}

    And switch them from your interface (buttonA,buttonB)


    Code:
    buttonA.setOnClickListener(new View.OnClickListener() {
    
    
                @Override
                public void onClick(View v) {
                                     setListAdapter(mAdapterA);    
                }
            });
    
    
    buttonB.setOnClickListener(new View.OnClickListener() {
    
    
                @Override
                public void onClick(View v) {
                                     setListAdapter(mAdapterB);    
                }
            });

Remove Ads

http://www.scramblerducati.org/

Sponsored Links

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Similar Threads

  1. Add a editview to a listview
    By shawrie in forum Beginning Developers
    Replies: 0
    Last Post: 09-21-2011, 02:43 PM
  2. bind webservice to listview
    By s.aijaz1 in forum Beginning Developers
    Replies: 2
    Last Post: 07-08-2011, 08:28 PM
  3. bind webservice to listview
    By s.aijaz1 in forum Introductions & Site Assistance
    Replies: 1
    Last Post: 07-04-2011, 09:04 PM

Search tags for this page

listviuew

Click on a term to search our sites for related topics.
Android Forum