android - ActionBar with tabs, crash when I push tab with WebView -



android - ActionBar with tabs, crash when I push tab with WebView -

i have created tabs in mainactivity. tabs declared correctly, , loaded perfectly. next these tabs, programme stops. webview declared in fragment1.xml

public class fragmentstab1 extends fragment implements actionbar.tablistener { private fragment mfragment; webview navegador1; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // view fragment1.xml getactivity().setcontentview(r.layout.fragment1); try{ navegador1 = (webview) getview().findviewbyid(r.id.webkit1); websettings websettings = navegador1.getsettings(); websettings.setjavascriptenabled(true); websettings.setsaveformdata(false); navegador1.loadurl("http://www.google.com"); } grab (exception e) { e.printstacktrace(); } navegador1.setwebviewclient(new webviewclient(){ @override public boolean shouldoverrideurlloading(webview view, string url){ homecoming false; } }); } public void ontabselected(tab tab, fragmenttransaction ft) { // todo auto-generated method stub mfragment = new fragmentstab1(); // attach fragment1.xml layout ft.add(android.r.id.content, mfragment); ft.attach(mfragment); } public void ontabunselected(tab tab, fragmenttransaction ft) { // todo auto-generated method stub // remove fragment1.xml layout ft.remove(mfragment); } public void ontabreselected(tab tab, fragmenttransaction ft) { // todo auto-generated method stub } }

logcat errors :

06-23 06:59:50.156: w/system.err(1917): java.lang.nullpointerexception 06-23 06:59:50.156: w/system.err(1917): @ com.example.prueba.fragmentstab1.oncreate(fragmentstab1.java:24) 06-23 06:59:50.166: w/system.err(1917): @ android.app.fragment.performcreate(fragment.java:1673) 06-23 06:59:50.166: w/system.err(1917): @ android.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:854) 06-23 06:59:50.176: w/system.err(1917): @ android.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1057) 06-23 06:59:50.176: w/system.err(1917): @ android.app.backstackrecord.run(backstackrecord.java:682) 06-23 06:59:50.176: w/system.err(1917): @ android.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1435) 06-23 06:59:50.176: w/system.err(1917): @ android.app.fragmentmanagerimpl$1.run(fragmentmanager.java:441) 06-23 06:59:50.176: w/system.err(1917): @ android.os.handler.handlecallback(handler.java:730) 06-23 06:59:50.176: w/system.err(1917): @ android.os.handler.dispatchmessage(handler.java:92) 06-23 06:59:50.176: w/system.err(1917): @ android.os.looper.loop(looper.java:137) 06-23 06:59:50.176: w/system.err(1917): @ android.app.activitythread.main(activitythread.java:5103) 06-23 06:59:50.186: w/system.err(1917): @ java.lang.reflect.method.invokenative(native method) 06-23 06:59:50.186: w/system.err(1917): @ java.lang.reflect.method.invoke(method.java:525) 06-23 06:59:50.186: w/system.err(1917): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:737) 06-23 06:59:50.186: w/system.err(1917): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) 06-23 06:59:50.186: w/system.err(1917): @ dalvik.system.nativestart.main(native method) 06-23 06:59:50.186: d/androidruntime(1917): shutting downwards vm 06-23 06:59:50.186: w/dalvikvm(1917): threadid=1: thread exiting uncaught exception (group=0xb2f5b648) 06-23 06:59:50.236: e/androidruntime(1917): fatal exception: main 06-23 06:59:50.236: e/androidruntime(1917): java.lang.nullpointerexception 06-23 06:59:50.236: e/androidruntime(1917): @ com.example.prueba.fragmentstab1.oncreate(fragmentstab1.java:33) 06-23 06:59:50.236: e/androidruntime(1917): @ android.app.fragment.performcreate(fragment.java:1673) 06-23 06:59:50.236: e/androidruntime(1917): @ android.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:854) 06-23 06:59:50.236: e/androidruntime(1917): @ android.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1057) 06-23 06:59:50.236: e/androidruntime(1917): @ android.app.backstackrecord.run(backstackrecord.java:682) 06-23 06:59:50.236: e/androidruntime(1917): @ android.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1435) 06-23 06:59:50.236: e/androidruntime(1917): @ android.app.fragmentmanagerimpl$1.run(fragmentmanager.java:441) 06-23 06:59:50.236: e/androidruntime(1917): @ android.os.handler.handlecallback(handler.java:730) 06-23 06:59:50.236: e/androidruntime(1917): @ android.os.handler.dispatchmessage(handler.java:92) 06-23 06:59:50.236: e/androidruntime(1917): @ android.os.looper.loop(looper.java:137) 06-23 06:59:50.236: e/androidruntime(1917): @ android.app.activitythread.main(activitythread.java:5103) 06-23 06:59:50.236: e/androidruntime(1917): @ java.lang.reflect.method.invokenative(native method) 06-23 06:59:50.236: e/androidruntime(1917): @ java.lang.reflect.method.invoke(method.java:525) 06-23 06:59:50.236: e/androidruntime(1917): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:737) 06-23 06:59:50.236: e/androidruntime(1917): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) 06-23 06:59:50.236: e/androidruntime(1917): @ dalvik.system.nativestart.main(native method)

android android-fragments android-webview

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -