Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in a Listview on list item click how can i get the title(the name ) of the selected item? android

I have listview that binds from sqlite and groups by KEY_TITLE(field) so i need to get the name of the item that is 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 string selectedIteme = l.getSelectedItem().getSOMETNIG?

like image 464
denza Avatar asked Dec 28 '25 16:12

denza


2 Answers

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

you can pick the selected item value like this

 @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);
    }
like image 160
Avi Dhiman Avatar answered Dec 30 '25 06:12

Avi Dhiman


Try this in your onClick method..

Map<String, String> selection = (Map<String, String>) listView.getItemAtPosition(position);
 String count = selection.get("count");
 String title = selection.get("title");
like image 34
coder_For_Life22 Avatar answered Dec 30 '25 05:12

coder_For_Life22