在main.xml中
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button"
android:onClick="openActivity"/>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Leilei6</string>
<string name="action_settings">Settings</string>
<string name="hello">Hello world!</string>
<string name="windowtitle">新的Activity</string>
<string name="content">I am new</string>
<string name="button">open new world!</string>
</resources>
在MainActivity.java中
public void openActivity(View v) {
Intent intent = new Intent();
intent.setAction("cn.itcast.zhangxx");
intent.addCategory("cn.itcast.category");
startActivity(intent);
}
在AndroidManifest.xml中
<activity
android:name=".OtherActivity"
android:label="@string/windowtitle" >
<intent-filter>
<action android:name="cn.itcast.zhangxx"/>
<category android:name="cn.itcast.category"/>
</intent-filter>
</activity>
在other.xml中
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/content" />
</LinearLayout>
在OtherActivity.java中
setContentView(R.layout.other);
}
详解参考:http://blog.csdn.net/liuhe688/article/details/7162988#
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button"
android:onClick="openActivity"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Leilei6</string>
<string name="action_settings">Settings</string>
<string name="hello">Hello world!</string>
<string name="windowtitle">新的Activity</string>
<string name="content">I am new</string>
<string name="button">open new world!</string>
</resources>
在MainActivity.java中
public void openActivity(View v) {
Intent intent = new Intent();
intent.setAction("cn.itcast.zhangxx");
intent.addCategory("cn.itcast.category");
startActivity(intent);
}
在AndroidManifest.xml中
<activity
android:name=".OtherActivity"
android:label="@string/windowtitle" >
<intent-filter>
<action android:name="cn.itcast.zhangxx"/>
<category android:name="cn.itcast.category"/>
</intent-filter>
</activity>
在other.xml中
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/content" />
</LinearLayout>
在OtherActivity.java中
setContentView(R.layout.other);
}
详解参考:http://blog.csdn.net/liuhe688/article/details/7162988#