android - Error while using fragment manager -


package com.c2.layoutsdemo;  import java.util.arraylist;  import android.app.activity; import android.app.fragmentmanager; import android.os.bundle; import android.widget.arrayadapter;  public class todolistactivity extends activity implements newitemfragment.onnewitemaddedlistener { 

also if make arraylist , addar adapter final per example, additional errors regarding initialization of arraylist.

    arraylist<string> todoitems;     arrayadapter<string> aa;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_to_do_list);      fragmentmanager fm= getfragmentmanager();     todolistfragment todolistfragment = (todolistfragment)fm.findfragmentbyid(r.layout.todolistfragment); 

the above line gives error : todolistfragment cannot resolved or not field

    todoitems = new arraylist<string>();     aa = new arrayadapter<string>(this,android.r.layout.simple_list_item_1,todoitems);       todolistfragment.setlistadapter(aa);       }      @override     public void onnewitemadded(string newitem) {         todoitems.add(newitem);         aa.notifydatasetchanged();      }  } 

you getting fragment id, instead of use

r.layout.todolistfragment 

you should use

r.id.theidofthefragment 

and make sure, in layout file; fragment declaration contains , id attribute:

<fragment android:name="xxx,xxx,xxx.todolistfragment"             android:id="@+id/theidofthefragment"             ....  /> 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -