Intereting Posts

Фрагмент Tabhost Ошибка: java.lang.IllegalStateException: нет закладки, известной для тега null При недоступности подключения к Интернету

Я сначала проверяю подключение к Интернету, и после этого я начинаю свою деятельность, и мне приходится сталкиваться с этой проблемой, когда я использую Tab Host.

Я также добавляю свой добавочный код узла вкладки в try catch, но он даже не поймает исключение.

Код XML:

<android.support.v4.app.FragmentTabHost android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#999999" > <FrameLayout android:id="@android:id/tabcontent" android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="0" /> </android.support.v4.app.FragmentTabHost> 

Мой код Java

  cd = new ConnectionDetector(Alumni_MainActivity.this); // Check if Internet present if (!cd.isConnectingToInternet()) { // Internet Connection is not present alert.showAlertDialog(Alumni_MainActivity.this, "Internet Connection Error", "Please connect to working Internet connection", false); // stop executing code by return return; } try { tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); tabHost.setup(this, getSupportFragmentManager(), R.id.fragment_container); addTab("Chat", R.drawable.chaticon, ChatRoom.class, tabHost,null); addTab("Contacts", R.drawable.contacticon, Memeber_view.class, tabHost, null); addTab("Gallery", R.drawable.gallery, Galler_View.class, tabHost, null); addTab("Event", R.drawable.event, EventList.class, tabHost,null); addTab("More", R.drawable.moreicon, More.class, tabHost,null); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } 

Ошибка: 08-20 10:02:04.195: E/AndroidRuntime(13462): FATAL EXCEPTION: main 08-20 10:02:04.195: E/AndroidRuntime(13462): java.lang.IllegalStateException: No tab known for tag null 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.support.v4.app.FragmentTabHost.doTabChanged(FragmentTabHost.java:330) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.support.v4.app.FragmentTabHost.onAttachedToWindow(FragmentTabHost.java:280) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.View.dispatchAttachedToWindow(View.java:11988) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2495) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2502) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2502) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2502) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2502) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1363) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1139) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4879) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.Choreographer.doCallbacks(Choreographer.java:579) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.Choreographer.doFrame(Choreographer.java:548) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.os.Handler.handleCallback(Handler.java:725) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.os.Handler.dispatchMessage(Handler.java:92) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.os.Looper.loop(Looper.java:153) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.app.ActivityThread.main(ActivityThread.java:5311) 08-20 10:02:04.195: E/AndroidRuntime(13462): at java.lang.reflect.Method.invokeNative(Native Method) 08-20 10:02:04.195: E/AndroidRuntime(13462): at java.lang.reflect.Method.invoke(Method.java:511) 08-20 10:02:04.195: E/AndroidRuntime(13462): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 08-20 10:02:04.195: E/AndroidRuntime(13462): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 08-20 10:02:04.195: E/AndroidRuntime(13462): at dalvik.system.NativeStart.main(Native Method) 08-20 10:02:04.195: E/AndroidRuntime(13462): FATAL EXCEPTION: main 08-20 10:02:04.195: E/AndroidRuntime(13462): java.lang.IllegalStateException: No tab known for tag null 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.support.v4.app.FragmentTabHost.doTabChanged(FragmentTabHost.java:330) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.support.v4.app.FragmentTabHost.onAttachedToWindow(FragmentTabHost.java:280) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.View.dispatchAttachedToWindow(View.java:11988) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2495) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2502) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2502) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2502) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2502) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1363) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1139) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4879) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.Choreographer.doCallbacks(Choreographer.java:579) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.Choreographer.doFrame(Choreographer.java:548) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.os.Handler.handleCallback(Handler.java:725) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.os.Handler.dispatchMessage(Handler.java:92) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.os.Looper.loop(Looper.java:153) 08-20 10:02:04.195: E/AndroidRuntime(13462): at android.app.ActivityThread.main(ActivityThread.java:5311) 08-20 10:02:04.195: E/AndroidRuntime(13462): at java.lang.reflect.Method.invokeNative(Native Method) 08-20 10:02:04.195: E/AndroidRuntime(13462): at java.lang.reflect.Method.invoke(Method.java:511) 08-20 10:02:04.195: E/AndroidRuntime(13462): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 08-20 10:02:04.195: E/AndroidRuntime(13462): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 08-20 10:02:04.195: E/AndroidRuntime(13462): at dalvik.system.NativeStart.main(Native Method)

Пожалуйста, помогите мне, я поражен.

Заранее спасибо!!

Solutions Collecting From Web of "Фрагмент Tabhost Ошибка: java.lang.IllegalStateException: нет закладки, известной для тега null При недоступности подключения к Интернету"