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[] { R.id.title };

        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
    @Override
    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
com.android.internal.sortcur...@12345678

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(R.id.title);
    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
(position);
    String title = cursor.getString(cursor.getColumnIndexOrThrow
(RingtoneManager.EXTRA_RINGTONE_TITLE));

On Apr 27, 10:26pm, Glen Humphrey <glendon.humphr...@gmail.com>



--~--~---------~--~----~------------~-------~--~----~



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. How to build custom kernel for gphone(g1)?

I have followed this to
BUILT THE ANDROID EMULATOR-SPECIFIC KERNEL:
http://android.git.kernel.org/?p=platform/external/qemu.git;a=blob;f=docs/KERNEL.TXT;h=7387e55d5362be8e2dc00e634277a9fdbdd66db6;hb=ceb00f8c44e26d948e28b7a3ccef8fd2068589d9
.
I modified some source files and It was built successfully. And now I
wonder if this kernel can be put into my G1 directly? How? Or this
kernel I built is only for emulator, than how to build a kernel for
gphone?

Thanks

--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. How i can pass my String to Another page

Hi ,

  I am new to Android development.....I want to transfer transfer my
String(username) to another page.....
i m having some problems on it...so wil u please tel me the answer.....

with regards
S.Raghav

--~--~---------~--~----~------------~-------~--~----~

3. My sub activity doesn't die...

4. Other home applications breaking our app

5. source not found

6. User defined application properties

7. Eclipse: Debug Tab - Dead Debug Sessions.