I\'m making class like as below
// All necessary imports are here
public class More extends Activity {
String[] MoreItems = { \"Transfers\", \"Budgets\
There are two option to handle click event for each row.
1) If your class extends ListActivity
, you can override following method.
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
//do something here using the position in the array
}
2) Handle click event of row in getView()
method
row.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
Your "More" class has to extend ListActivity instead of Activity, then you can override onListItemClick
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
//do something here using the position in the arrya
}
Edit: Forgot to say, in your layout your ListView has to be called: android:id="@android:id/list"
you can also do like this..
moreListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Log.d("############","Items " + MoreItems[arg2] );
}
});
For example:
ListView lv = getListView();
lv.setAdapter(listAdapter);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
Intent i = new Intent(More.this, NextActvity.class);
//If you wanna send any data to nextActicity.class you can use
i.putExtra(String key, value.get(position));
startActivity(i);
}
});