Hi I created a ListView extending the ListActivity class, it works all fine but when I click on a item it doesn't get highlighted.
This is how I populate the list:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.row_event, null);
}
Event ev = items.get(position);
if (ev != null) {
//line one
TextView eventName = (TextView) v.findViewById(R.id.toptext);
//line two
TextView eventDate = (TextView) v.findViewById(R.id.bottomtext);
if (eventName != null) {
eventName.setText(ev.getEventName()); }
if (eventDate != null){
eventDate.setText(ev.getEventDate());
}
}
return v;
}
}
Thank you!
Make sure that the two textviews are set to android:focusable="false"
so they do not override the listview's focus behavior. Also, the problem may be from setting a background for the textviews. Setting the background for the ListView items overrides the default focus behavior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With