android - Sliding tab with calendar in fragment -


i having 2 sliding tabs working. want calendar in 1 of tab giving me error.

error

12-16 09:58:54.437: e/androidruntime(2495): fatal exception: main 12-16 09:58:54.437: e/androidruntime(2495): process: com.project.homepagedemo, pid: 2495 12-16 09:58:54.437: e/androidruntime(2495): java.lang.nullpointerexception 12-16 09:58:54.437: e/androidruntime(2495):     @ com.bharatwellness.mainactivities.diarytabonecalorieconsumed.oncreateview(diarytabonecalorieconsumed.java:66) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.support.v4.app.fragment.performcreateview(fragment.java:1504) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:942) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1121) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.support.v4.app.backstackrecord.run(backstackrecord.java:682) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1484) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.support.v4.app.fragmentmanagerimpl.executependingtransactions(fragmentmanager.java:482) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.support.v4.app.fragmentpageradapter.finishupdate(fragmentpageradapter.java:141) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.support.v4.view.viewpager.populate(viewpager.java:1073) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.support.v4.view.viewpager.populate(viewpager.java:919) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.support.v4.view.viewpager.onmeasure(viewpager.java:1441) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.view.measure(view.java:16497) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5125) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.widget.framelayout.onmeasure(framelayout.java:310) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.view.measure(view.java:16497) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5125) 12-16 09:58:54.437: e/androidruntime(2495):     @ com.android.internal.widget.actionbaroverlaylayout.onmeasure(actionbaroverlaylayout.java:327) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.view.measure(view.java:16497) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5125) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.widget.framelayout.onmeasure(framelayout.java:310) 12-16 09:58:54.437: e/androidruntime(2495):     @ com.android.internal.policy.impl.phonewindow$decorview.onmeasure(phonewindow.java:2291) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.view.measure(view.java:16497) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.viewrootimpl.performmeasure(viewrootimpl.java:1912) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.viewrootimpl.measurehierarchy(viewrootimpl.java:1109) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1291) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:996) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:5600) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.choreographer$callbackrecord.run(choreographer.java:761) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.choreographer.docallbacks(choreographer.java:574) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.choreographer.doframe(choreographer.java:544) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:747) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.os.handler.handlecallback(handler.java:733) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.os.handler.dispatchmessage(handler.java:95) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.os.looper.loop(looper.java:136) 12-16 09:58:54.437: e/androidruntime(2495):     @ android.app.activitythread.main(activitythread.java:5001) 12-16 09:58:54.437: e/androidruntime(2495):     @ java.lang.reflect.method.invokenative(native method) 12-16 09:58:54.437: e/androidruntime(2495):     @ java.lang.reflect.method.invoke(method.java:515) 12-16 09:58:54.437: e/androidruntime(2495):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:785) 12-16 09:58:54.437: e/androidruntime(2495):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:601) 

my oncreate method

public view oncreateview(layoutinflater inflater, viewgroup container,             bundle savedinstancestate) {          view rootview = inflater.inflate(r.layout.tab_one_calorie_consumed, container, false);          _calendar = calendar.getinstance(locale.getdefault());         month = _calendar.get(calendar.month) + 1;         year = _calendar.get(calendar.year);         log.d(tag, "calendar instance:= " + "month: " + month + " " + "year: "                 + year);          selecteddaymonthyearbutton = (button) this.getview().findviewbyid(r.id.selecteddaymonthyear);         selecteddaymonthyearbutton.settext("selected: ");          prevmonth = (imageview) this.getview().findviewbyid(r.id.prevmonth);         prevmonth.setonclicklistener(this);          currentmonth = (textview) this.getview().findviewbyid(r.id.currentmonth);         currentmonth.settext(dateformat.format(datetemplate,                 _calendar.gettime()));          nextmonth = (imageview) this.getview().findviewbyid(r.id.nextmonth);         nextmonth.setonclicklistener(this);          calendarview = (gridview) this.getview().findviewbyid(r.id.calendar);          // initialised         adapter = new gridcelladapter(getactivity().getapplicationcontext(),                 r.id.calendar_day_gridcell, month, year);         adapter.notifydatasetchanged();         calendarview.setadapter(adapter);         return rootview;     } 

i have check twice nothing should null. working if using directly in main activity.

change

  selecteddaymonthyearbutton = (button) this.getview().findviewbyid(r.id.selecteddaymonthyear); 

to

  selecteddaymonthyearbutton = (button) rootview.findviewbyid(r.id.selecteddaymonthyear); 

and same other views.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -