I've been trying to contsruct a list, I'm having problems. I get a Null Pointe Exception
My code is below, I have a TabHost, from which I call new activity (via Intent), that will populate my Tabcontent area, see below
- Code: Select all
public class TabPage extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tabs);
.....
.....
host.addTab(host.newTabSpec("one")
.setIndicator("One")
.setContent(new Intent(this, DataList.class)));
The DataList.class is below
- Code: Select all
public class DataList extends Activity {
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
String[] dataArray = new String[] {"111111","211111","3111111"};
int [] to = new int[] {R.id.newsItem};
ListView lv = (ListView) findViewById(R.id.list_x);
ArrayAdapter arrayAdapter = new ArrayAdapter (this, R.layout.tab_row, R.id.listItem, dataArray);
lv.setAdapter(arrayAdapter);
The XML is as below
This is tab_row.xml file,
- Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@+id/listItem" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Below is the tabs.xml file,
- Code: Select all
<?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 xmlns:android="http://schemas.android.com/apk/res/android"
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">
<ListView
android:id = "@+id/listn_x"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</FrameLayout>
</LinearLayout>
</TabHost>
Any idea on what I,m doing wrong?
Thanks in advance for your thoughts


