Srikanth Naidu Srikanth Naidu - 1 year ago 71
Android Question

How to get the value of a Listview item which is clicked in android?

I have this below code access the ListView item value into string and display it in alert?

ListView shot = getListView();

public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {

String S = arg1.getContext().toString();
AlertDialog.Builder alertbox = new AlertDialog.Builder(this);

// set the message to display

Answer Source

maybe this example will help you

  lv.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view,
        int position, long id) {
      // When clicked, show a toast with the TextView text
      Toast.makeText(getApplicationContext(), ((TextView) view).getText(),

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download