Simple Listview Example In Android

Hello Friends,

Today we have discussed about the list-view. If you are new for android development. You must know about the develop list-view. And It is useful for our developing. From exploring the various concepts related to fundamentals and to locations and maps, I would like to look at a few UI elements.

This listview are simple and the code given below.

First you have to create layout file for listview.

<ListView android:id=“@id/android:list” android:layout_width=”fill_parent”
android:layout_height=”wrap_content” />

Now Class declaration should be like this.

public class listview extends ListActivity {

Then define one array string[]

private String all_dis_list[] = { “DEVELOPER”, “APPLICATION”, “ANDROID”,
“DEVAPPANDROID”, “TUTORIALS”, “JAVA”, “PROGRAMMING”, “EXAMPLES” };

Then setListAdapter()

setListAdapter(new ArrayAdapter(this,
android.R.layout.simple_list_item_1, all_dis_list));

And click event of listview

protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Object o = this.getListAdapter().getItem(position);
String developer = o.toString();
Toast.makeText(this, “Selected Item: ” + ” ” + developer,
Toast.LENGTH_LONG).show();

}

Screen Shot For this Programming…

That’s it….

{filelink=4}

 More Code…

>>   Twitter OAuth – Authentication In Android

>>   IPhone UITable View In Android

>>   Full Screen Activity In Android

>>   Add Admob To Your Application

>>   Page Curl Effect In Android