android - setText to TextView when using the inflater -


in android app have been using relativelayout , inflater. need set text in textview, have used inflater, cannot set text code.

xml file activity_title

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:padding="10dp" android:layout_height="match_parent" android:background="#000000" >  <textview     android:id="@+id/text_title"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignparentleft="true"     android:layout_alignparentright="true"     android:text="text" />  </relativelayout> 

2 xml file

<relativelayout             android:id="@+id/rel_container"             android:layout_width="fill_parent"             android:layout_height="fill_parent"             android:layout_alignparentright="true"             android:layout_aligntop="@+id/linearlayout1"             android:layout_torightof="@+id/linearlayout1"              > </relativelayout> 

so code, using inflater

relativelayout = (relativelayout) findviewbyid(r.id.rel_container);     ((viewgroup) relativelayout).removeallviews();     (int = 0; < titlecalendar.length; i++) {         getapplicationcontext();         vi= (layoutinflater)   getapplicationcontext().getsystemservice(context.layout_inflater_service);         v = vi.inflate(r.layout.activity_title, null);           textviewc = (textview) v.findviewbyid(r.id.text_title);         textviewc.settext("sdfsfasfasfasfasf");         textviewc.settextcolor(color.parsecolor("#ffffff"));           final relativelayout.layoutparams params = new  relativelayout.layoutparams(relativelayout.layoutparams.match_parent,relativelayout.layoutparams.wrap_content);          params.addrule(relativelayout.below, addcnvrttime);           textviewc.setlayoutparams(params);         ((viewgroup) relativelayout).addview(v, 0, params);      } 

i cannot see text, set on textview

this inflater elements:

layoutinflater inflater = getlayoutinflater(); view customview = inflater.inflate(r.layout.your_layout_inflater, null); textview text = (textview)customview.findviewbyid(r.id.your_text_view); text.settext("blablablablabla"); 

why not put textview direct inside layout , do

textview text = (textview)findviewbyid(r.id.your_text_view); text.settext("blablablablabla"); 

?


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -