In short: you don't, you can't, you won't :)

Explanations here:
http://android-developers.blogspot.com/2008/12/touch-mode.html

On Fri, Dec 26, 2008 at 3:26 PM, Timothy DeWees <whtdrgn...@gmail.com> wrote:
>
> 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();
>    }
>
> >
>



-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to