android - Changing Background color of a view inside a Fragment -


ok, new problem;

i trying change background color of view inside fragment on touch event.

it setup , working fine. seems background won't change of color.

i suspect happens because view has other views on on fill parent if changes color won't able see it.

anyhow have set views color color.transparent still not work...

here xml file:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff" android:id = "@+id/lay_1">  <textview     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="@string/position"     android:id="@+id/pos"/>   <viewflipper     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_below="@id/pos"     android:id="@+id/flipper_1"     >      <include layout="@layout/cart"/>      <include layout="@layout/ang"/>      <include layout="@layout/data_graph"/>  </viewflipper> 

if need more information don't mind asking it.

thanks lot.

luis.

i had similar issue , should try create method called @ oncreate of fragment update inside of fragment view (background color, text...) ex: public static linearlayout getcolor(layoutinflater inflater, viewgroup container, boolean bf){

int i; view v; textview t; linearlayout ll;  int r = (int)math.round(math.random()*255+1); int g = (int)math.round(math.random()*255+1); int b = (int)math.round(math.random()*255+1);  i=color.argb(200,r,g,b); if(bf){     ll = (linearlayout )inflater.inflate(r.layout.fragment_card_front, container, false);     v=ll.findviewbyid(r.id.frag_card_front);     v.setbackgroundcolor(i);     t=(textview) ll.findviewbyid(r.id.textf);     t.settext(""+i); } else{         ll = (linearlayout )inflater.inflate(r.layout.fragment_card_back, container, false);         v=ll.findviewbyid(r.id.frag_card_back);         v.setbackgroundcolor(i);         t=(textview) ll.findviewbyid(r.id.textb);         t.settext(""+i);  }  return ll;  }   public static class cardfrontfragment extends fragment {      @override     public view oncreateview(layoutinflater inflater, viewgroup container,             bundle savedinstancestate) {         linearlayout ll = (linearlayout ) getcolor(inflater, container,true);      return ll;     } }   public static class cardbackfragment extends fragment {     @override     public view oncreateview(layoutinflater inflater, viewgroup container,             bundle savedinstancestate) {         linearlayout ll = (linearlayout ) getcolor(inflater, container,false);               return ll;     } } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -