Skip to content

Instantly share code, notes, and snippets.

@sharifulislam52
Last active March 1, 2018 15:21
Show Gist options
  • Save sharifulislam52/6375367b2dea2fa3556fb8af147fcad1 to your computer and use it in GitHub Desktop.
Save sharifulislam52/6375367b2dea2fa3556fb8af147fcad1 to your computer and use it in GitHub Desktop.
ListView list_view = (ListView) findViewById(R.id.list_view_id);
ArrayAdapter<String> myadapter = new ArrayAdapter<String>(this, R.layout.textView_xml_for_show_list_text, itemes);
list_view.setAdapter(myadapter);
list_view.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
String value = (String) list_view.getItemAtPosition(i);
Toast.makeText(MainActivity.this,"Position : " + i + "Value : " + value, Toast.LENGTH_LONG).show();
}
});
// list_view, list_view_id, myadapter, textView_xml_for_show_list_text
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</TextView>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment