Android studio Internet跳转活动

2023-03-16,,

<?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"
>
<TextView
android:id="@+id/tv_first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="第一个页面"
android:layout_gravity="center"
android:textSize="40dp"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onclick"
android:text="进入第二个页面"
/>
</LinearLayout>

创建按钮的onclick方法

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

public void onclick(View view) {
Intent intent = new Intent(this,SecondActivity.class);
startActivity(intent);
}
}

随后会产生一个相应的布局文件

<?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"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="第二个页面"
android:layout_gravity="center"
android:textSize="40dp"
/>

</LinearLayout>

Android studio Internet跳转活动的相关教程结束。

《Android studio Internet跳转活动.doc》

下载本文的Word格式文档,以方便收藏与打印。