private String lv_arr[]={"Android","iPhone","BlackBerry","AndroidPeople"};
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.mylist);
lv1=(ListView)findViewById(R.id.ListView01);
// By using setAdpater method in listview we an add string array in list.
lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , lv_arr));
//getListView().setTextFilterEnabled(true);
}
protected void onListItemClick(ListView l, View v, int position, long id) {
//super.onListItemClick(l, v, position, id);
Object o = this.getListAdapter().getItem(position);
String pen = o.toString();
if (pen.equals("Android"))
{
Intent myIntent = new Intent(v.getContext(), Catedral.class);
startActivityForResult(myIntent, 0);
Toast.makeText(this, "Catedral", Toast.LENGTH_LONG).show();
}
private String lv_arr[]={Android,iPhone,BlackBerry,AndroidPeople}; public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.mylist); lv1=(ListView)findViewById(R.id.ListView01); // By using
Share
Calling
toStringonObjectjust returns the memory reference of the object. This is whypendoes not match.I’m not that familiar with
ListAdapter, have you tried casting the return to aStringbefore assigning to a reference: