Skip to main content

Posts

Showing posts with the label tablerow

Android: Selector isn"t working as expected in TableRow selection

I have a TAbleLayout in my XML with 1 row i.e. te headings row. Other all rows, I add dynamically. I want to make a row selected on clicking it & on touching it. I added clickListener to each row and am able to trap click event. But when the mouse is pressed or kept pressed, I see color change, then again it comes to normal color. I want the color to stay changed until I click other row or click somewhere else to deactivate the selected row. My selector XML code : <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Active state --> <item android:state_selected="true" android:state_focused="false" android:state_pressed="false" android:drawable="@android:color/transparent" /> <!-- Inactive state--> <item android:state_selected="false" android:state_focused="false" android:state