Having trouble getting ListView to show selected item as highlighted

by Timothy DeWees » Sat, 27 Dec 2008 07:08:09 GMT


Sponsored Links
 Hello,

I've seen a few post on this but have never seen or understood the
solution.  I have an application that is showing a list of items from
a database.  I extended the CursorAdapter and added an icon in front
of the item to easily show type.

When I navigate the items using the track-pad, it shows the selected
item; however, when I click the item, the selection goes away.  It's
still there and when I use the track-pad again, it seems to be getting
the focus back and then I can scroll.

What I want to happen is for the list item to appear highlighted when
I click it just like when I navigate to it with the trackpad.

Any suggestions?

Here are my onClick and onItemSelected:

    @Override
    protected void onListItemClick(ListView l, View v, int position,
long id) {
        super.onListItemClick(l, v, position, id);
        setSelection(position);
        movieId = id;
    }
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mDbHelper = new MoviesDbAdapter(this);
        mDbHelper.open();
        Button filterButton = (Button)findViewById
(R.id.filter_button);
        filterButton.setOnClickListener( new View.OnClickListener() {
                public void onClick(View v){
                        EditText filter = 
(EditText)findViewById(R.id.filter_text);
                        filterExpr = filter.getText().toString();
                        fillData();
                }
        });
        getListView().setAddStatesFromChildren(false);
        getListView().setItemsCanFocus(true);
        getListView().setOnItemSelectedListener( new
OnItemSelectedListener() {
                public void onItemSelected(AdapterView<?> parent, View v, int
possition, long id) {
                        v.setSelected(true);
                        movieId = id;
                }
                public void onNothingSelected(AdapterView<?> parent) {
                        parent.setSelection(-1);
                }
        });
        fillData();
    }

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



Other Threads

1. Android.mk for external/dosfstools missing on Donut

Hi,

1. Why is Android.mk missing for dosfstools under external? This is on
Donut branch, I find the Android.mk existing on Cupcake branch.
       Is there any particular reason for disabling the build of
dosfstools?

2. In volmgr_vfat.c there is a reference to

"static char FSCK_MSDOS_PATH[] = "/system/bin/fsck_msdos" but don't
find anything under external?
Is something missing here? Believe that dosfsck is to be used here,
but thatz disabled from being built !!! It was built in cupcake branch
though.


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

2. Problem saving bitmap in JPEG format

Hi Guys,


Im trying to save a bitmap in a JPEG format, and i can see that the
image is always stored with a lower quality even if i give the
compression level as 100, however for PNG it is working fine.


SImilaarly during Media.insert() or getContentResolver().insert() the
image is stored with a lesser wuality, I can see in that the
compression level is 50 in the Media.java, however i tried to create
my own method for the same function with quality 100, but still im
facing the same problem, any help on the same?

IM stuck up with this issue pretty badly, waiting for your tips


Regards,
R.Karthik

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

3. Catch Android Exceptions

4. System time update : NTP server

5. unsubscribe to group mot working

6. build my apk with platform certificate in sd

7. How to force Activity in landscape mode without Activity restart