我是新来的Android程序,但没有为Java。
我已经得到关于在NPE此错误信息:
12-09 10:29:58.247: D/dalvikvm(471): GC freed 711 objects / 54912 bytes in 163ms
12-09 10:29:58.337: D/dalvikvm(471): GC freed 45 objects / 1720 bytes in 37ms
12-09 10:29:58.457: D/AndroidRuntime(471): Shutting down VM
12-09 10:29:58.457: W/dalvikvm(471): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
12-09 10:29:58.457: E/AndroidRuntime(471): Uncaught handler: thread main exiting due to uncaught exception
12-09 10:29:58.457: E/AndroidRuntime(471): java.lang.NullPointerException
12-09 10:29:58.457: E/AndroidRuntime(471): at android.widget.TabHost.dispatchWindowFocusChanged(TabHost.java:295)
12-09 10:29:58.457: E/AndroidRuntime(471): at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:661)
12-09 10:29:58.457: E/AndroidRuntime(471): at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:661)
12-09 10:29:58.457: E/AndroidRuntime(471): at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:661)
12-09 10:29:58.457: E/AndroidRuntime(471): at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:661)
12-09 10:29:58.457: E/AndroidRuntime(471): at android.view.ViewRoot.handleMessage(ViewRoot.java:1819)
12-09 10:29:58.457: E/AndroidRuntime(471): at android.os.Handler.dispatchMessage(Handler.java:99)
12-09 10:29:58.457: E/AndroidRuntime(471): at android.os.Looper.loop(Looper.java:123)
12-09 10:29:58.457: E/AndroidRuntime(471): at android.app.ActivityThread.main(ActivityThread.java:4363)
12-09 10:29:58.457: E/AndroidRuntime(471): at java.lang.reflect.Method.invokeNative(Native Method)
12-09 10:29:58.457: E/AndroidRuntime(471): at java.lang.reflect.Method.invoke(Method.java:521)
12-09 10:29:58.457: E/AndroidRuntime(471): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
12-09 10:29:58.457: E/AndroidRuntime(471): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
12-09 10:29:58.457: E/AndroidRuntime(471): at dalvik.system.NativeStart.main(Native Method)
12-09 10:29:58.467: I/dalvikvm(471): threadid=7: reacting to signal 3
12-09 10:29:58.467: E/dalvikvm(471): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
它的驾驶我疯了。 我搜索了一个在线解决方案,虽然我看到的错误引用多次,他们要么没有发布的解决方案或解决方案不为我工作。
下面是我的文件。 我感谢所有帮助您可以给我。
WorkbenchTicketDetailsActivity.java
package com.android.fm.workbench;
import com.android.fm.workbench.R;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class WorkbenchTicketDetailsActivity extends WorkbenchActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ticketdetails);
TabHost host = (TabHost)findViewById(R.id.tabhost);
host.setup();
TabSpec ticketdetailTab = host.newTabSpec("ticketdetails");
ticketdetailTab.setIndicator(getResources().getString(R.string.tablabel_ticketdetails),getResources().getDrawable(android.R.drawable.ic_menu_manage));
ticketdetailTab.setContent(R.id.TableLayout_TicketDetails);
host.setCurrentTabByTag("ticketdetails");
}
}
ticketdetails.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/fm_background"
android:orientation="vertical" >
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/LinearLayout1"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<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">
<ScrollView
android:id="@+id/ScrollViewTicketDetails"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical">
<TableLayout
android:id="@+id/TableLayout_TicketDetails"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="*">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="test"
/>
</TableRow>
</TableLayout>
</ScrollView>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
的Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.fm.workbench"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".WorkbenchActivity" >
</activity>
<activity android:name="WorkbenchTicketDetailsActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/><category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="WorkbenchLoginActivity"></activity>
<activity android:name="WorkbenchSplashActivity">
</activity>
</application>
</manifest>
我appologize如果有,我只是没有看到一个简单的解决方案。 我一直在敲打我的头靠在了半晌一张桌子,我知道有在这里可以快速找到问题很多巨星。
我试图从TabView的Android的网站加入如下代码,并取代我现有ticketdetail.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="fill_parent"
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>
仍然给我一个空指针异常!