In the list item, in the list item, click, how can I get the title (name) of the selected item? android

I have a listview that links to sqlite and groups by KEY_TITLE (field), so I need to get the name of the item that was clicked

   @Override
    protected void onListItemClick(ListView l, View v, int position, long id)
    {
        super.onListItemClick(l, v, position, id);
        Intent i=new Intent(this,detail.class);

        i.putExtra(DatabaseIN.KEY_TITLE,SOMETHING THAT I NEED!);

        //startActivity(i);
        startActivityForResult(i,ACTIVITY_EDIT);
    }

      

// maybe something like this selectedIteme = l.getSelectedItem (). getSOMETNIG?

+3


source to share


2 answers


check this tutorial can help you http://www.vogella.de/articles/AndroidListView/article.html

you can select the value of the selected item like



 @Override
        protected void onListItemClick(ListView l, View v, int position, long id) {
            Cursor c = (Cursor) arg0.getAdapter().getItem(arg2);

Intent i=new Intent(getApplicationContext(),Xyz.class);
i.putExtra("abc", c.getString(1));
startActivity(i);
    }

      

+4


source


Try this in onClick method.



Map<String, String> selection = (Map<String, String>) listView.getItemAtPosition(position);
 String count = selection.get("count");
 String title = selection.get("title");

      

+2


source







All Articles