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();
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---