Created
July 4, 2019 16:26
-
-
Save rubemlrm/3a0e8d8b00717f8d81d1fd1cb3a8cbd0 to your computer and use it in GitHub Desktop.
ListViewClick
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
listView.setOnItemClickListener(new OnItemClickListener() { | |
@Override | |
public void onItemClick(AdapterView<?> parent, View view, | |
int position, long id) { | |
Toast.makeText(getApplicationContext(), | |
"Click ListItem Number " + position, Toast.LENGTH_LONG) | |
.show(); | |
switch(position) { | |
case CONST_FRAGMENT_1 : | |
//Start fragment 1 | |
... | |
... | |
} | |
} | |
}); | |
-------- example 2 | |
listview.setOnItemClickListener(new OnItemClickListener(){ | |
@Override | |
public void onItemClick(AdapterView<?>adapter,View v, int position){ | |
ItemClicked item = adapter.getItemAtPosition(position); | |
Intent intent = new Intent(Activity.this,destinationActivity.class); | |
//based on item add info to intent | |
startActivity(intent); | |
} | |
}); | |
public ItemClicked getItem(int position){ | |
return items.get(position); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment