On nothing selected event : ListView « UI « Android

On nothing selected event


package app.test;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;

public class Test extends Activity {
  ListView listView;
  private String[] data = { "1", "2", "3","4", "5", "6" };
  public void onCreate(Bundle savedInstanceState) {
    listView = new ListView(this);
    listView.setAdapter(new ArrayAdapter<String>(this,
        android.R.layout.simple_list_item_1, data));
    OnItemSelectedListener itemSelectedListener = new OnItemSelectedListener(){
      public void onItemSelected(AdapterView<?> parent, View arg1,
          int position, long arg3) {
        setTitle("t:  "+parent.getItemAtPosition(position).toString());

      public void onNothingSelected(AdapterView<?> arg0) {


Related examples in the same category

1.Using ExpandableListView
2.Using ListView
3.Using SimpleAdapter to fill data to ListView
4.Custom cell Renderer for ListView
5.Provide xml layout for ListView Item
6.Fill contact information to ListView
8.Use AbsListView OnScrollListener(AbsListView.OnScrollListener), AbsListView#setOnItemScrollListener(AbsListView.OnItemScrollListener)} to display the first letter of the visible range of cheeses.
9.This demo illustrates the use of CHOICE_MODE_MULTIPLE_MODAL, a.k.a. selection mode on ListView.
10.FileList extends ListView
11.set ListView Height Based On Children
12.Adding a List
13.Lunch List
14.Get Item index in item click event
15.Create List