Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android app - how to display a list of items and make them clickable

Tags:

android

I need to display a list of text items to the screen and make them clickable. So it would be something like a list of links on a web application.

How can I do that in an Android Activity screen?

It would be some random number of items that I have to pull from a db and display all as links.

Any idea how that can be done?

like image 328
GeekedOut Avatar asked Mar 09 '12 16:03

GeekedOut


People also ask

What is an ArrayAdapter in Android?

android.widget.ArrayAdapter<T> You can use this adapter to provide views for an AdapterView , Returns a view for each object in a collection of data objects you provide, and can be used with list-based user interface widgets such as ListView or Spinner .

How can you react to click events on an item of a ListView?

Place an empty linearlayout below the listview by setting an appropriate height to the listview. Place an onClick() method to that linear layout. That must do it.

What is required by a ListView in order to display the items?

In order to display items in the list, call setAdapter(android. widget. ListAdapter) to associate an adapter with the list.


1 Answers

You should read the doc about ListActivity, ListView and follow the Hello ListView tutorial.

like image 86
Benoit Duffez Avatar answered Oct 13 '22 11:10

Benoit Duffez