I have a TableRow which contains a LinearLayout, and then this LinearLayout contains a TextView. What I want is, once the TextView is clicked, the entire TableRow would change its background color.
I've tried to use getParent() and performClick() to pass the click event from TextView to TableRow. The onClick() method of TableRow does get called, but its background color does not change.
Of course I've set the selector by using either
row.setBackgroundResource(R.drawable.menu_item_bgcolor);
or
row.setBackgroundDrawable(activity.getResources().getDrawable(R.drawable.menu_item_bgcolor));
Doesn't work. Can anyone provide any insight into this? Thanks,
Below is the selector xml file:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/menu_item_pressed" />
<item android:state_focused="true" android:drawable="@drawable/menu_item_pressed" />
<item android:drawable="@drawable/menu_item_normal" />
</selector>