android - Fragment UI not getting displayed -


activity layout : activity_text_entry.xml

<?xml version="1.0" encoding="utf-8" ?> <framelayout            xmlns:android="http://schemas.android.com/apk/res/android"            android:layout_height="match_parent"            android:layout_width="match_parent"            android:id="@+id/fragmentcontainer_textentry"            /> 

fragment layout : fragment_text_entry.xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"      >  <edittext      android:id="@+id/text_entry_date"      android:layout_width="match_parent"      android:layout_height="wrap_content"      android:hint="@string/choose_date_text"      android:layout_marginleft="16dp"      android:layout_marginright="16dp"       />  <requestfocus />  <edittext      android:id="@+id/text_entry_title"      android:layout_width="match_parent"      android:layout_height="wrap_content"      android:hint="@string/choose_title_text"     android:layout_marginbottom="16dp"     android:layout_marginleft="16dp"     android:layout_marginright="16dp"     android:layout_margintop="16dp" >        </edittext>  <edittext     android:id="@+id/text_entry_content"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_marginbottom="16dp"     android:layout_marginleft="16dp"     android:layout_marginright="16dp"     android:layout_margintop="16dp"     android:ems="100"     android:gravity="left|top"     android:hint="@string/enter_text_here"     android:inputtype="textmultiline" >   </edittext>  <linearlayout      android:layout_height="match_parent"     android:layout_width="match_parent"     android:orientation="horizontal"     android:gravity="center|bottom"     >      <button         android:id="@+id/text_entry_button_save"         android:text="@string/action_save"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:padding="10dp" />      <button         android:id="@+id/text_entry_button_cancel"         android:text="@string/action_cancel"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:padding="10dp" />  </linearlayout>  </linearlayout> 

activity : textentryactivity

package com.app.journal_v001;  import android.os.bundle; import android.support.v4.app.fragment; import android.support.v4.app.fragmentactivity; import android.support.v4.app.fragmentmanager; import android.widget.toast;  public class textentryactivity extends fragmentactivity {      @override     protected void oncreate(bundle savedinstancestate)     {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_text_entry);            fragmentmanager m_fm_text_entry_activity = getsupportfragmentmanager();          fragment m_f_text_entry_activity = m_fm_text_entry_activity.findfragmentbyid(r.id.fragmentcontainer_textentry);          if(m_f_text_entry_activity == null)         {              m_f_text_entry_activity = new fragment();              m_fm_text_entry_activity.begintransaction()                                     .add(r.id.fragmentcontainer_textentry, m_f_text_entry_activity)                                     .commit();           }     }  } 

fragment : textentryfragment

package com.app.journal_v001;  import android.os.bundle; import android.support.v4.app.fragment; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.button; import android.widget.toast;  public class textentryfragment extends fragment {  //private button m_btn_text_entry_save; //private button m_btn_text_entry_cancel;  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate); }  @override public view oncreateview(layoutinflater inflate,viewgroup parent,bundle savedinstancestate) {     view v = inflate.inflate(r.layout.fragment_text_entry, parent, false);         return v; }  } 

i trying render textentryfragment(fragment) textentryactivity(activity). have kept series of toasts in various places track , can see code getting executed till fragmentmanager's fragmenttransaction , after not seem call fragment's oncreate/oncreateview.

can point me whats wrong ? when execute not able see fragment ui being rendered.

remove

if(m_f_text_entry_activity == null)         {              m_f_text_entry_activity = new fragment();              m_fm_text_entry_activity.begintransaction()                                     .add(r.id.fragmentcontainer_textentry, m_f_text_entry_activity)                                     .commit();           } 

and replace

m_fm_text_entry_activity.begintransaction()                                     .add(r.id.fragmentcontainer_textentry, m_f_text_entry_activity)                                     .commit(); 

==================edit==================================

also

textentryfragment m_f_text_entry_activity=new textentryfragment(); 

instead of

fragment m_f_text_entry_activity = m_fm_text_entry_activity.findfragmentbyid(r.id.fragmentcontainer_textentry); 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -