当我点击按钮打开另一个活动,即标签主机活动,但在我的情况下,当我点击按钮没有显示,我没有得到任何错误。只是空白屏幕显示。下面是log cat
04-12 15:16:30.799 25332-25332/? D/dalvikvm: Not late-enabling CheckJNI (already on)
04-12 15:16:35.129 25332-25332/com.novityrecharge E/Trace: error opening trace file: No such file or directory (2)
04-12 15:16:36.969 25332-25332/com.novityrecharge D/ImageLoader: Initialize ImageLoader with configuration
04-12 15:16:37.488 25332-25335/com.novityrecharge D/dalvikvm: GC_CONCURRENT freed 211K, 8% free 5458K/5895K, paused 152ms+4ms, total 416ms
04-12 15:16:37.521 25332-25332/com.novityrecharge W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
04-12 15:16:37.521 25332-25332/com.novityrecharge I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
04-12 15:16:37.528 25332-25332/com.novityrecharge W/dalvikvm: VFY: unable to resolve interface method 18180: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
04-12 15:16:37.528 25332-25332/com.novityrecharge D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
04-12 15:16:37.528 25332-25332/com.novityrecharge I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
04-12 15:16:37.528 25332-25332/com.novityrecharge W/dalvikvm: VFY: unable to resolve interface method 18184: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
04-12 15:16:37.528 25332-25332/com.novityrecharge D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
04-12 15:16:37.839 25332-25332/com.novityrecharge D/dalvikvm: GC_FOR_ALLOC freed 43K, 7% free 5497K/5895K, paused 32ms, total 33ms
04-12 15:16:37.866 25332-25332/com.novityrecharge I/dalvikvm-heap: Grow heap (frag case) to 6.242MB for 685600-byte allocation
04-12 15:16:37.908 25332-25335/com.novityrecharge D/dalvikvm: GC_CONCURRENT freed <1K, 7% free 6166K/6599K, paused 13ms+3ms, total 41ms
04-12 15:16:38.079 25332-25332/com.novityrecharge D/dalvikvm: GC_FOR_ALLOC freed 0K, 7% free 6166K/6599K, paused 116ms, total 116ms
04-12 15:16:38.152 25332-25332/com.novityrecharge I/dalvikvm-heap: Grow heap (frag case) to 6.611MB for 386900-byte allocation
04-12 15:16:38.339 25332-25338/com.novityrecharge D/dalvikvm: GC_FOR_ALLOC freed 0K, 7% free 6544K/6983K, paused 171ms, total 171ms
04-12 15:16:38.349 25332-25332/com.novityrecharge I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
04-12 15:16:38.349 25332-25332/com.novityrecharge W/dalvikvm: VFY: unable to resolve virtual method 460: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
04-12 15:16:38.349 25332-25332/com.novityrecharge D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-12 15:16:38.378 25332-25332/com.novityrecharge I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
04-12 15:16:38.378 25332-25332/com.novityrecharge W/dalvikvm: VFY: unable to resolve virtual method 482: Landroid/content/res/TypedArray;.getType (I)I
04-12 15:16:38.378 25332-25332/com.novityrecharge D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-12 15:16:39.068 25332-25332/com.novityrecharge D/libEGL: loaded /system/lib/egl/libEGL_emulation.so
04-12 15:16:39.089 25332-25332/com.novityrecharge D/libEGL: loaded /system/lib/egl/libGLESv1_CM_emulation.so
04-12 15:16:39.154 25332-25332/com.novityrecharge D/libEGL: loaded /system/lib/egl/libGLESv2_emulation.so
04-12 15:16:39.418 25332-25332/com.novityrecharge D/: HostConnection::get() New Host Connection established 0x2a12c998, tid 25332
04-12 15:16:41.112 25332-25332/com.novityrecharge W/EGL_emulation: eglSurfaceAttrib not implemented
04-12 15:16:41.300 25332-25332/com.novityrecharge D/OpenGLRenderer: Enabling debug mode 0
04-12 15:16:41.333 25332-25332/com.novityrecharge I/Choreographer: Skipped 159 frames! The application may be doing too much work on its main thread.
04-12 15:16:42.806 25332-25332/com.novityrecharge I/Choreographer: Skipped 80 frames! The application may be doing too much work on its main thread.
04-12 15:16:44.440 25332-25332/com.novityrecharge I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
04-12 15:16:44.440 25332-25332/com.novityrecharge W/dalvikvm: VFY: unable to resolve virtual method 423: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
04-12 15:16:44.449 25332-25332/com.novityrecharge D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-12 15:16:44.449 25332-25332/com.novityrecharge I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
04-12 15:16:44.459 25332-25332/com.novityrecharge W/dalvikvm: VFY: unable to resolve virtual method 425: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
04-12 15:16:44.459 25332-25332/com.novityrecharge D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-12 15:16:44.878 25332-25332/com.novityrecharge D/text: 1234
04-12 15:16:44.888 25332-25332/com.novityrecharge I/Choreographer: Skipped 76 frames! The application may be doing too much work on its main thread.
04-12 15:16:45.818 25332-25332/com.novityrecharge W/EGL_emulation: eglSurfaceAttrib not implemented
04-12 15:16:46.054 25332-25332/com.novityrecharge I/Choreographer: Skipped 68 frames! The application may be doing too much work on its main thread.
04-12 15:16:47.792 25332-25332/com.novityrecharge I/Choreographer: Skipped 103 frames! The application may be doing too much work on its main thread.
04-12 15:16:52.486 25332-25332/com.novityrecharge D/AndroidRuntime: Shutting down VM
04-12 15:16:52.486 25332-25332/com.novityrecharge W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x40a122a0)
04-12 15:16:53.159 25332-25335/com.novityrecharge D/dalvikvm: GC_CONCURRENT freed 852K, 16% free 6114K/7239K, paused 84ms+16ms, total 171ms
04-12 15:20:41.062 25332-25337/com.novityrecharge I/dalvikvm: threadid=3: reacting to signal 3
04-12 15:20:41.589 25332-25337/com.novityrecharge I/dalvikvm: Wrote stack traces to '/data/anr/traces.txt'
SMSActivityTab.java
公共类SMSActivityTab扩展了AppCompatActivity {
TabHost myTabHost;
// LocalActivityManager mlam; TabWidget tw;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.smsactivitytab);
if(!(Thread.getDefaultUncaughtExceptionHandler() instanceof ExceptionHandler))
{
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this,"LoginActivity"));
}
//mlam = new LocalActivityManager(this, false);
// mlam.dispatchCreate(savedInstanceState);
myTabHost =(TabHost) findViewById(android.R.id.tabhost);
myTabHost.setup();
TabHost.TabSpec prepaid = myTabHost.newTabSpec("tab1");
TabHost.TabSpec dth = myTabHost.newTabSpec("tab2");
TabHost.TabSpec postpaid = myTabHost.newTabSpec("tab3");
//Below name is display on screen
prepaid.setIndicator(getResources().getString(R.string.lbl_prepaidrecharge));
prepaid.setContent(new Intent(SMSActivityTab.this, SMSPrepaid.class));
dth.setIndicator(getResources().getString(R.string.lbl_dthrecharge));
dth.setContent(new Intent(SMSActivityTab.this, SMSDTH.class));
postpaid.setIndicator(getResources().getString(R.string.lbl_prepaidrecharge));
postpaid.setContent(new Intent(SMSActivityTab.this, SMSPostpaid.class));
myTabHost.addTab(prepaid);
myTabHost.addTab(dth);
myTabHost.addTab(postpaid);
myTabHost.setCurrentTab(0);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// action with ID action_refresh was selected
case R.id.action_signout:
BaseActivity.logout(SMSActivityTab.this);
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onBackPressed() {
Intent intent = new Intent(SMSActivityTab.this, LoginActivity.class);
startActivity(intent);
finish();
}
@Override
protected void onResume(){
super.onResume();
//mlam.dispatchResume();
}
@Override
protected void onPause(){
super.onPause();
//mlam.dispatchPause(isFinishing());
}
}
smsactivitytab.xml
<?xml version="1.0" encoding="utf-8"?>
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>
答案 0 :(得分:0)
我认为你的问题就在这一行
myTabHost =(TabHost) findViewById(android.R.id.tabhost);
您需要将此行更改为
myTabHost =(TabHost) findViewById(android.R.id.tabs);