java - Android: Change Image Swipe View -
i want create swipe view few pages.
they have same layout, wanted display other content on each page, imageviews , textviews inside.
on every swipe, have change text content or image's drawable displaying different pages.
so use
((textview) rootview.findviewbyid(r.id.text1)) .settext(r.string.my_text1);
this works ..
but this:
((imageview) rootview.findviewbyid(r.id.image1)) .setimageresource(r.drawable.pic1);
or this:
((imageview) rootview.findviewbyid(r.id.image1)) .setimagedrawable(getresources().getdrawable(r.drawable.pic1);
doesn't.
the app crashes, , logcat says:
07-31 18:31:41.467: e/androidruntime(792): fatal exception: main 07-31 18:31:41.467: e/androidruntime(792): java.lang.nullpointerexception 07-31 18:31:41.467: e/androidruntime(792): @ com.keksarmee.mcguide.friendly$objectfragment.oncreateview(friendly.java:119) 07-31 18:31:41.467: e/androidruntime(792): @ android.support.v4.app.fragment.performcreateview(fragment.java:1460) 07-31 18:31:41.467: e/androidruntime(792): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:911) 07-31 18:31:41.467: e/androidruntime(792): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1088) 07-31 18:31:41.467: e/androidruntime(792): @ android.support.v4.app.backstackrecord.run(backstackrecord.java:682) 07-31 18:31:41.467: e/androidruntime(792): @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1444) 07-31 18:31:41.467: e/androidruntime(792): @ android.support.v4.app.fragmentmanagerimpl.executependingtransactions(fragmentmanager.java:461) 07-31 18:31:41.467: e/androidruntime(792): @ android.support.v4.app.fragmentstatepageradapter.finishupdate(fragmentstatepageradapter.java:163) 07-31 18:31:41.467: e/androidruntime(792): @ android.support.v4.view.viewpager.populate(viewpager.java:1064) 07-31 18:31:41.467: e/androidruntime(792): @ android.support.v4.view.viewpager.populate(viewpager.java:911) 07-31 18:31:41.467: e/androidruntime(792): @ android.support.v4.view.viewpager.onmeasure(viewpager.java:1432) 07-31 18:31:41.467: e/androidruntime(792): @ android.view.view.measure(view.java:15518) 07-31 18:31:41.467: e/androidruntime(792): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:4825) 07-31 18:31:41.467: e/androidruntime(792): @ android.widget.framelayout.onmeasure(framelayout.java:310) 07-31 18:31:41.467: e/androidruntime(792): @ android.view.view.measure(view.java:15518) 07-31 18:31:41.467: e/androidruntime(792): @ android.widget.linearlayout.measurevertical(linearlayout.java:847) 07-31 18:31:41.467: e/androidruntime(792): @ android.widget.linearlayout.onmeasure(linearlayout.java:588) 07-31 18:31:41.467: e/androidruntime(792): @ android.view.view.measure(view.java:15518) 07-31 18:31:41.467: e/androidruntime(792): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:4825) 07-31 18:31:41.467: e/androidruntime(792): @ android.widget.framelayout.onmeasure(framelayout.java:310) 07-31 18:31:41.467: e/androidruntime(792): @ com.android.internal.policy.impl.phonewindow$decorview.onmeasure(phonewindow.java:2176) 07-31 18:31:41.467: e/androidruntime(792): @ android.view.view.measure(view.java:15518) 07-31 18:31:41.467: e/androidruntime(792): @ android.view.viewrootimpl.performmeasure(viewrootimpl.java:1874) 07-31 18:31:41.467: e/androidruntime(792): @ android.view.viewrootimpl.measurehierarchy(viewrootimpl.java:1089) 07-31 18:31:41.467: e/androidruntime(792): @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1265) 07-31 18:31:41.467: e/androidruntime(792): @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:989) 07-31 18:31:41.467: e/androidruntime(792): @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:4351) 07-31 18:31:41.467: e/androidruntime(792): @ android.view.choreographer$callbackrecord.run(choreographer.java:749) 07-31 18:31:41.467: e/androidruntime(792): @ android.view.choreographer.docallbacks(choreographer.java:562) 07-31 18:31:41.467: e/androidruntime(792): @ android.view.choreographer.doframe(choreographer.java:532) 07-31 18:31:41.467: e/androidruntime(792): @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:735) 07-31 18:31:41.467: e/androidruntime(792): @ android.os.handler.handlecallback(handler.java:725) 07-31 18:31:41.467: e/androidruntime(792): @ android.os.handler.dispatchmessage(handler.java:92) 07-31 18:31:41.467: e/androidruntime(792): @ android.os.looper.loop(looper.java:137) 07-31 18:31:41.467: e/androidruntime(792): @ android.app.activitythread.main(activitythread.java:5041) 07-31 18:31:41.467: e/androidruntime(792): @ java.lang.reflect.method.invokenative(native method) 07-31 18:31:41.467: e/androidruntime(792): @ java.lang.reflect.method.invoke(method.java:511) 07-31 18:31:41.467: e/androidruntime(792): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) 07-31 18:31:41.467: e/androidruntime(792): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) 07-31 18:31:41.467: e/androidruntime(792): @ dalvik.system.nativestart.main(native method)
i'm sorry copy&pasting log...
but couldn't find way change drawable. eclipse not showing errors...
:( richie
ok, i've found solution.
in xml file have use
id="@android:id/icon"
instead of
id="@+id/image1"
Comments
Post a Comment