button - android - how to have a clickable AND checkable textview -


i want have following: textview .)changes background when clicked .)maintains background until clicked again

it comes down "checkable" state, couldnt figure out how works. here xml using background:

<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android">  <!-- pressed --> <item android:drawable="@drawable/menuselected" android:state_pressed="true" />  <!-- checked --> <item android:drawable="@drawable/menuselected" android:state_checked="true" />  <!-- default --> <item android:drawable="@drawable/transpixel"/>  </selector> 

update: partly works now. adopted of code http://kmansoft.com/2011/01/11/checkable-image-button/ custom textview. did actually, need functionality of radio button well. can check textview, cant uncheck it. see why case?

you can use checkedtextview checkmark null , background selectable

<checkedtextview xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:checkmark="@null"     android:background="@drawable/selectable"/> 

your selectable can be

<selector xmlns:android="http://schemas.android.com/apk/res/android">     <item android:state_checked="true" android:drawable="@drawable/selector" /> </selector> 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -