selector - change textview background until select another textview in android -


i have develop android application.

i have using below textview:

    <textview     android:id="@+id/deals"     android:layout_width="wrap_content"     android:layout_height="50dip"     android:background="@drawable/best_deal_bg"     android:text="deals"    /> 

this background of these textview:

 <?xml version="1.0" encoding="utf-8"?>  <selector xmlns:android="http://schemas.android.com/apk/res/android">  <item android:drawable="@drawable/menu_active" android:state_enabled="true"       android:state_pressed="true" />   </selector> 

here .,if have click these textview means tiime ly shows background.

but wish need output like.have shows background until select textview.

how can ?? please give me solution these ???

edit:

i have set background on android textview onclik functionality:

deals = (textview) findviewbyid(r.id.deals);       deals.setonclicklistener(new view.onclicklistener() {       public void onclick(view arg0) {         deals.setbackground(getresources().getdrawable(r.drawable.best_deal_bg));         intent intent = new intent(getparent(),deals.class);         tabgroupactivity parentactivity = (tabgroupactivity) getparent();         parentactivity.startchildactivity("bestdeals",intent);                }     }); 

here getting below error :

*07-11 10:07:50.593: e/androidruntime(816): java.lang.nosuchmethoderror: android.widget.textview.setbackground *

edit:

deals = (textview) findviewbyid(r.id.deals);       deals.setonclicklistener(new view.onclicklistener() {       public void onclick(view arg0) {     view lastclickedview=null;             if(v != lastclickedview) {              v.setbackground(getresources().getdrawable(r.drawable.best_deal_bg));                  lastclickedview.setbackground(getresources().getdrawable(r.drawable.message_icon));          }         lastclickedview = v;       intent intent = new intent(getparent(),deals.class);         tabgroupactivity parentactivity = (tabgroupactivity) getparent();         parentactivity.startchildactivity("bestdeals",intent);                }        }); 

here getting below error :

e/androidruntime(883): java.lang.nosuchmethoderror: android.view.view.setbackground

what's worng in code.pls give me solution these ???

dynamically change in code on selection of textview use

yourtextview.setbackgrounddrawable(getresources().getdrawable(r.drawable.best_deal_bg)); 

and if want remove background use

yourtextview.setbackground(null); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -