import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class ListEx extends ListActivity {
/** Called when the activity is first created. */
String s[];
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
ListView l1=getListView();
s=getResources().getStringArray(R.array.s);
l1.setChoiceMode(2);
l1.setTextFilterEnabled(true);
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_expandable_list_item_1,s));
}
public void onListItemClick(ListView parent, View v, int position, long id)
{
parent.setItemChecked(position,parent.isItemChecked(position));
Toast.makeText(this,"you have selected" +":"+ s[position],
Toast.LENGTH_SHORT).show();
}
}
No comments:
Post a Comment