add tab cause exception

by AndroidGeek » Tue, 10 Feb 2009 00:58:05 GMT


Sponsored Links
 ey,
I tried to add composite control to tabHost, I followed android
example Tab3.java to do that.
I created a new activity with listview, textview as following:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="@+id/goal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff49501" android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<ListView android:id="@+id/goallist"
android:layout_width="fill_parent"
android:layout_height="150px">
</ListView>
<TextView android:id="@+id/healthTipLabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20px"
android:text="Health Tips" android:textSize="20sp"
android:typeface="sans" android:textStyle="bold"
android:layout_gravity="center_horizontal">
</TextView>
<ListView android:id="@+id/healthtiplist"
android:layout_width="fill_parent"
android:layout_height="200px"
android:layout_marginTop="20px">
</ListView>
</LinearLayout>
</ScrollView>

and my java:

public class GoalView extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.goalcontrol);
}
}

manifest file:

<activity android:name=".views.GoalView">
<intent-filter>
<action
android:name="android.intent.action.MAIN"></action>
</intent-filter>
</activity>

Tab.java:

public class MyActivity extends TabActivity {

DatabaseAdapter da = null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);

ArrayList<String> script = loadCreateScript();
da = (DatabaseAdapter.getInstance(this, script));

final TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec("Goals").setIndicator("Goals",

getResources().getDrawable(R.drawable.goal_icon)).setContent(new
Intent(this, GoalView.class)));

But when I run my app, I got runtime exception:
InvocationTargetException (id=xxxxxxxxxxx)
Unable to start activity ComponentInfo{com.mycompany/
com.mycomapny.MyActivity}: java.lang.RuntimeException: Unable t



add tab cause exception

by AndroidGeek » Tue, 10 Feb 2009 01:05:03 GMT


 nd also found in my control java file override onCreate(Bundle
saveInstanceState) method,
super.onCreate(savedInstanceState) cause error, because
saveInstanceState = null;

Thanks

On Feb 9, 11:57am, AndroidGeek <binli...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


add tab cause exception

by Francisco » Sat, 07 Mar 2009 02:01:31 GMT


 ey did you find out what was wrong? im having a very similar issue.

On Feb 9, 9:04am, AndroidGeek <binli...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~