NullPointerException:null ????

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

NullPointerException:null ????

Postby zhugeliang » Mon Dec 14, 2009 10:00 am

I just copied source code that use tabhost ,tabwidget from this link http://www.codemobiles.com/forum/viewto ... ?p=434#434 and it doesnt work. So It show me this text in main.xml


NullPointerException:null

what does it mean ?


CODE

package com.codemobiles.android.demo;

import android.app.TabActivity;
import android.os.Bundle;
import android.widget.TabHost;

public class TabDemo extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost mTabHost = getTabHost();

mTabHost.addTab(mTabHost.newTabSpec("tab_test1")
.setIndicator("Calculator", getResources().getDrawable(R.drawable.calculator))
.setContent(R.id.textview1));

mTabHost.addTab(mTabHost.newTabSpec("tab_test2")
.setIndicator("YouTube", getResources().getDrawable(R.drawable.youtube))
.setContent(R.id.textview2));

mTabHost.addTab(mTabHost.newTabSpec("tab_test3")
.setIndicator("Mail", getResources().getDrawable(R.drawable.mail))
.setContent(R.id.textview3));

mTabHost.addTab(mTabHost.newTabSpec("tab_test4")
.setIndicator("Map", getResources().getDrawable(R.drawable.map))
.setContent(R.id.textview4));

mTabHost.addTab(mTabHost.newTabSpec("tab_test5")
.setIndicator("Camara", getResources().getDrawable(R.drawable.camara))
.setContent(R.id.textview5));

mTabHost.setCurrentTab(0);

}
}





<?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">
<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">
<TextView
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Tab No1#" />
<TextView
android:id="@+id/textview2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Tab No2#" />
<TextView
android:id="@+id/textview3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Tab No3#" />

<TextView
android:id="@+id/textview4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Tab No4#" />

<TextView
android:id="@+id/textview5"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Tab No5#" />
</FrameLayout>
</LinearLayout>
</TabHost>
zhugeliang
Developer
Developer
 
Posts: 29
Joined: Mon Dec 14, 2009 9:49 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests