Hi,

ich have in res/layout/ two xml files:

main.xml
test.xml

I want to click a button in main.xml, and set the conent view to
test.xml.
The buttons id in main is "testshow".

The Code in my java file is:

package com.androidapp;

import android.app.TabActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TabHost;

public class androidapp extends TabActivity {
    private TabHost mTabHost;
    private Button mButton;

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

        mTabHost = getTabHost();

        mTabHost.addTab(mTabHost.newTabSpec
("tab_timetable").setIndicator("test1").setContent(R.id.tab1));
        mTabHost.addTab(mTabHost.newTabSpec("tab_current").setIndicator
("test2").setContent(R.id.tab2));
        mTabHost.addTab(mTabHost.newTabSpec("tab_options").setIndicator
("test3").setContent(R.id.tab3));

        mTabHost.setCurrentTab(0);

        mButton = (Button) findViewById(R.id.testshow);

        mButton.setOnClickListener(new View.OnClickListener() {

                        public void onClick(View v) {
                                setContentView(R.layout.test);
                        }

                });


    }
}

It doenst work. The application force quit.
If i delete "setContentView(R.layout.test);" the application runs, but
the button have no code and doesnt show test.xml.

Anyone can help?

Regards,
Michael

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to