How To Highlight Row In Table Layout?
I have created dynamic text view at table row in table layout. I want to highlight theh current row while I click row in table layout. How can this be done?
Solution 1:
Below 2 lines should work fine. When creating the rows in a method
row.setFocusable("true");
row.setFocusableInTouchMode("true");
Solution 2:
The following layout options worked for me to make a table row clickable and respond visually like a button:
<TableRowstyle="@style/PlanAttribute"xmlns:android="http://schemas.android.com/apk/res/android"android:focusable="true"android:focusableInTouchMode="true"android:onClick="onRowSelected"android:clickable="true">
...
PlanAttribute style:
<stylename="PlanAttribute"><itemname="android:layout_width">fill_parent</item><itemname="android:layout_height">wrap_content</item><itemname="android:background">@drawable/divider_drawable</item></style>
divider_drawable.xml:
<?xml version="1.0" encoding="utf-8"?><selectorxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:state_pressed="true"><bitmapxmlns:android="http://schemas.android.com/apk/res/android"android:src="@drawable/divider_down"android:gravity="fill"/></item><itemandroid:state_focused="true"><bitmapxmlns:android="http://schemas.android.com/apk/res/android"android:src="@drawable/divider_selected"android:gravity="fill"/></item><itemandroid:state_focused="false"android:state_pressed="false"><bitmapxmlns:android="http://schemas.android.com/apk/res/android"android:src="@drawable/divider"android:gravity="fill"/></item></selector>
Post a Comment for "How To Highlight Row In Table Layout?"