Intent

来源:互联网 发布:人死后会去哪里知乎 编辑:程序博客网 时间:2024/06/16 09:07

intent Intent

1.Create a new second_layout.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical" ><Button    android:id="@+id/button_4"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:text="Button 4"    /></LinearLayout>

2.create SecondActivity extents Activity

package com.example.activitytest;import android.app.Activity;import android.os.Bundle;import android.view.Window;public class SecondActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        requestWindowFeature(Window.FEATURE_NO_TITLE);        setContentView(R.layout.second_layout);    }}

3.register for it

    <activity android:name=".SecondActivity">    </activity>

因为SecondActivity不是主活动,因此不需要配置标签中的内容.
4. Change the click event in FirstActivity

                Intent intent = new Intent(FirstActivity.this,SecondActivity.class);                startActivity(intent);
0 0
原创粉丝点击