I have a listView, I'm wondering how to get the position of the item selected in the ListView so that I can use this code under the OnItemClick method.
string selected = listView.getItemPosition().toString()
So then I can use the if / else clause or switch to say:
if (selected.positionEquals("0")) {
Intent i = new Intent(this, WebViewActivity.class);
i.putExtra("keyHTML", "file:///android_asset/page1.html");
startActivity(i);
I hope I made sense, please note, the listView.getItemPosition().toString() and selected.positionEquals was something I made up so you can get an idea of what I want.
Thanks!
EDIT
I just saw this from another question, I searched before asking this, but this just popped out. Do you think it will work in my case?
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
if(position == 1)
{
Intent myIntent = new Intent(YourActivity.this, SecondActivity.class);
startActivityForResult(myIntent, 0);
}
if(position == 2)
{
Intent myIntent = new Intent(YourActivity.this, ThirdActivity.class);
startActivityForResult(myIntent, 0);
}
}
});