how to get the string from a listview item

by Kent Yip » Tue, 28 Apr 2009 11:15:10 GMT

Sponsored Links
 i have a method that fill the list with items

// Depending on param, this method will display the list
    public void fillData( RingtoneManager rm, int type ) {
        // Set all type of sounds; notification, ringtone, alarm
        rm.setType( type );
        c = rm.getCursor();

        startManagingCursor( c );

        String[] from = new String[] { RingtoneManager.EXTRA_RINGTONE_TITLE
        int[] to = new int[] { };

        SimpleCursorAdapter rt =
            new SimpleCursorAdapter( this, R.layout.ringtones_row, c, from,
to );
        setListAdapter( rt );

    }// end fillData() method

when i select an item i want to be able to display the ringtone's title or
play the ringtone but i am having trouble doing so.

this get call when item is clicked

// Plays ringtone when cliking on the list item
    public void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);

        // play the ringtone selected or get text/string from listview

        Toast.makeText( this, text, Toast.LENGTH_SHORT ).show();

    }// end onListItemClick() method

i tried this: l.getItemAtPosition( position )

that return an object data. but i have no clues as to what i could use to
extract string title from it.

I use toString() to get and idea what i am accessing and it's a

please help, much appreciated.


how to get the string from a listview item

by Glen Humphrey » Tue, 28 Apr 2009 13:26:34 GMT

 Try something like this in your onListItemClick.

    TextView textView = (TextView) v.findViewById(;
    String text = textView.getText().toString();


Sponsored Links

how to get the string from a listview item

by Glen Humphrey » Tue, 28 Apr 2009 13:47:57 GMT

 You could also do something like this in your onListItemClick.

    SQLiteCursor cursor = (SQLiteCursor) l.getItemAtPosition
    String title = cursor.getString(cursor.getColumnIndexOrThrow

On Apr 27, 10:26pm, Glen Humphrey <>


how to get the string from a listview item

by Glen Humphrey » Tue, 28 Apr 2009 14:37:49 GMT

 Try using Cursor instead of SQLiteCursor.


Other Threads

1. Damaged SDcard with microsSD32GB with nexusone amd droid with android2.0 or higher version only

Good afternoon to all Developers

                         I am having problem with Google Nexus one and
Motorola droid phone.I am memory cards compatability tester.

Motorola Droid--------Firmware2.0.1

                           I have 32GB microSD card with me .when i
inserted inthe nexusone or droid its able to detct the card and its
showing capacity correctly and working fine. When i formatted it its
not able to format,its dispalys"damaged SDcard" and my card capacity
reduced to 1.99GB(at this point its formatting in FAT16).if i format
this card im pc again it comes back 32GB (Note:these cards are testing
card in our lab,cards relesed in market may not regain to origininal
capacity.i dont have any idead about this)

                          After several hours of testing i recognised
that for a fresh card if my free space is below 30GB(in my case it is
29.7GB ,ITS NEW CARD) Format fails.i would like to clarify one thing
there is no problem with 64MB,2GB,4GB,8GB,

                          i have almost 10 android mobiles same card
(i.e 32GB crad with Free space 29.7GB) is working fine with android
1.5 and 1.6. I am facing problem with 2.0 and 2.1.(AFTER 2.0 all fail)

                         one more intresting thing is all android
mobiles are compatable with 64GB ALSO.64GB format passed and working market 32GB AND 64GB microsd cards may not available,but we
are our company gonna relaese 32GB microsd card very soon.

more detail info:

1)we are able to change the card capacity in our lab if my card free
space is above 30GB there wii be no problem with format.

2)for example if i bought 2GB card and if i check properties there
will be some used space approxmately 64kb depends on manifacturer and
1.84GB free space and i am refering to this free sapce in my

I will look forward from all developers to fix this issue.

for any further details about this issue u can mail me at

Thanks and Regards


2. How to prevent animation when starting new task?

We are currently looking into methods how to implement tabs. TabHost
has serious limitations and is no option. Instead, we are
experimenting with our own tab solution, which has its own task
(activity stack) for each tab.

It's working well except that there's transition animation performed
by the system when launching a new task the first time. The
NO_ANIMATION parameter passed to startActivity has no effect in this
case. The animation breaks the app visually - is there a way to
prevent it?



3. Using mapquest

4. Eclair Browser Plugin Help

5. GsmCellLocation.getCid() format

6. AudioPool cleanup issues

7. AsyncTask and passing message back to UI Thread