私はこのコードを持っています:
public class InfoActions extends ActivityGroup{
TabHost tabHost;
TabSpec first;
TabSpec second;
View indicatorview1;
View indicatorview2;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// ToDo add your GUI initialization code here
setContentView(R.layout.infoactions);
tabHost=(TabHost)findViewById(R.id.tabhostsynchronisation);
tabHost.setup(getLocalActivityManager());
tabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);
indicatorview1 = android.view.LayoutInflater.from(this).inflate(R.layout.tabs_bg_styled, null);
first=tabHost.newTabSpec("Tab 1");
((TextView)indicatorview1.findViewById(R.id.tabsText)).setText("");
first.setIndicator(indicatorview1);
Intent in1 = new Intent(this, com.Orange.PrepareVisits.RoadmapsOnDevice.class);
first.setContent(in1);
indicatorview2 = android.view.LayoutInflater.from(this).inflate(R.layout.tabs_bg_styled, null);
second=tabHost.newTabSpec("Tab 2");
((TextView)indicatorview2.findViewById(R.id.tabsText)).setText("Informations");
second.setIndicator(indicatorview2);
Intent in2 = new Intent(this, com.Orange.Information.Informations.class);
second.setContent(in2);
tabHost.addTab(first);
tabHost.addTab(second);
}
これは私のtabs_bg_styled.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/tab_bg_selector"
android:padding="10dp"
android:gravity="center"
android:orientation="vertical"
>
<TextView
android:id="@+id/tabsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textSize="10dp"
android:textStyle="bold"
android:textColor="@drawable/tab_text_selector"
android:gravity="center"
/>
</LinearLayout>
そしてこれはログです:
ERROR AndroidRuntime at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
ERROR AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:99)
ERROR AndroidRuntime at android.os.Looper.loop(Looper.java:130)
ERROR AndroidRuntime at android.app.ActivityThread.main(ActivityThread.java:3701)
ERROR AndroidRuntime at java.lang.reflect.Method.invokeNative(Native Method)
ERROR AndroidRuntime at java.lang.reflect.Method.invoke(Method.java:507)
ERROR AndroidRuntime at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
ERROR AndroidRuntime at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
ERROR AndroidRuntime at dalvik.system.NativeStart.main(Native Method)
ERROR AndroidRuntime Caused by: java.lang.NullPointerException
ERROR AndroidRuntime at com.Orange.Information.InfoActions.onCreate(InfoActions.java:45)
ERROR AndroidRuntime at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
ERROR AndroidRuntime at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
これは私がエラーを受け取る行です:
((TextView)indicatorview1.findViewById(R.id.tabsText)).setText("");
誰かアイデアはありますか?