Android - Add TextView to custom activity to display in multiple activities -


i tried add textview custom activity display in multiple activities, nothing shown. custom activity code :

linearlayout layout;  public void setupfooter() {     layout = new linearlayout(this);     layout.setorientation(linearlayout.vertical);     layout.setgravity(android.view.gravity.bottom|android.view.gravity.center_horizontal);       textview tv = new textview(this);     tv.settext("abc");     layout.addview(tv); } 

this main_activity xml code want add footer :

<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/drawer_layout"     android:layout_width="match_parent"     android:layout_height="match_parent" >      <linearlayout         android:layout_width="match_parent"         android:layout_height="match_parent"         android:orientation="vertical" >          <framelayout             android:layout_width="match_parent"             android:layout_height="0dp"             android:layout_weight="1" >              <framelayout                 android:id="@+id/content_frame"                 android:layout_width="match_parent"                 android:layout_height="match_parent" />              <imagebutton                 android:id="@+id/btngototop"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_gravity="center|bottom"                 android:layout_margin="5dip"                 android:background="@drawable/buttongototop"                 android:padding="5dip"                 android:visibility="gone" />         </framelayout>          <textview             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:gravity="bottom"             android:text="textview" />     </linearlayout>      <listview         android:id="@+id/left_drawer"         android:layout_width="280dp"         android:layout_height="match_parent"         android:layout_gravity="start"         android:background="@color/white"         android:choicemode="singlechoice"         android:headerdividersenabled="false" />      <listview         android:id="@+id/right_drawer"         android:layout_width="280dp"         android:layout_height="match_parent"         android:layout_gravity="end"         android:background="@color/white"         android:choicemode="singlechoice"         android:headerdividersenabled="false" />  </android.support.v4.widget.drawerlayout> 

when call setupfooter() in extended activities, nothing shown. there problems code ? sorry bad english , helping me!

edited : added : addcontentview(layout, new layoutparams(layoutparams.wrap_content,layoutparams.wrap_content)); it's shown it's not placed @ bottom, how make stay @ bottom ?

you're creating 2 views in function, text view , linear layout. you're adding text view linear layout, aren't putting linear layout anywhere, isn't appearing. if want add linear layout in xml, need give id can reference findviewbyid, add text view that.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -