ListView and List Adapter

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

ListView and List Adapter

Postby radhika » Thu May 15, 2008 2:11 pm

Hi PlusMinus,

I can't get a hold of the ListView and ListAdapter.

1)Is it that if we use a ListView we should use ListAdapter?
2)How can i call a listener when the item in a list is clicked?
3)Also i have created a listview.xml that creates a list view and array.xml that gives the items to the list. how can i refer that items name inside the java code?
4)To use a listener method for the ListView should the ListAdapter be necessarily used?

Please help me out!!! :?:

Please clear my doubts through a tutorial.

Thanks in Advance.
Thank you
Regards
radhika
Desire to learn
radhika
Junior Developer
Junior Developer
 
Posts: 12
Joined: Wed May 14, 2008 8:09 am
Location: India

Top

Postby plusminus » Fri May 16, 2008 12:09 pm

Hello radhika,

1. yes (should not must)
2. Use OnItemClickListener, like:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 ListView lv = new ListView(this);
  2.  
  3.                 lv.setOnItemClickListener(new ...)
Parsed in 0.029 seconds, using GeSHi 1.0.8.4

3. Code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ArrayAdapter<String> x = new ArrayAdapter<String>(this, ..., this.getResources().getStringArray(ResIdOfArray));
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

4. No, the Adapter just fills in the items.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby HuXu » Sun Sep 28, 2008 4:11 am

Noob question

So I'm just trying to figure out how to build the basic list! I have 3 items "Item 1, Item 2, Item 3" ive seen ListView mentioned and ListAdapter but I'm not sure how to get them to work together so i have a list of clickable items. So could someone show me a basic "Item 1, Item 2, Item 3" and when they are clicked just show a dialog saying "Item 1 clicked" then just an ok button etc.?
You gotta start somewhere :/
HuXu
Freshman
Freshman
 
Posts: 4
Joined: Wed Sep 24, 2008 11:25 pm

Making items non-selectable

Postby taisa.santos » Wed Oct 29, 2008 4:20 pm

I have a listview but I don't want items to be selectable (with no highlight).

How can I do that?
Taisa Cristina
taisa.santos
Freshman
Freshman
 
Posts: 8
Joined: Mon Oct 27, 2008 5:51 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 7 guests