Intent 实现活动之间的跳转
2016-12-10 14:39
190 查看
转载请注明出处:http://blog.csdn.net/mr_leixiansheng/article/details/53558324
步骤:
1、新建要跳转的活动和布局文件
2、在AndroidManifest中实现注册
3、要跳转的活动中实现跳转
新建的活动和布局
主程序和布局
步骤:
1、新建要跳转的活动和布局文件
2、在AndroidManifest中实现注册
3、要跳转的活动中实现跳转
新建的活动和布局
package com.example.administrator.intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; /** * Created by Administrator on 2016/12/10. */ public class IntentActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.intent_layout); } }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:text="这是跳转后的活动" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout>
主程序和布局
/* 活动之间的跳转Intent */ package com.example.administrator.intent; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MainActivity.this, IntentActivity.class); //跳转设置 startActivity(intent); //开始跳转 } }); } }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:text="Button" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/button" /> </LinearLayout>
相关文章推荐
- 【Android】使用Intent实现Activity之间的跳转(创建一个Activity的过程)
- Android Intent实现Activity之间跳转并传值
- Intent 实现页面之间的跳转
- Intent用法——在活动之间跳转(一)
- 实现在不同活动之间的转换(Intent的用法)
- Android 显示的意图(Intent)的实现活动(Activity)之间的切换
- intent实现Activity之间跳转的各种传值
- Android Intent实现页面之间跳转
- 使用Intent实现活动间的跳转和数据传递
- Intent的用法——活动之间跳转
- 使用Intent实现Activity之间传值与跳转(转)
- android教学Intent实现activity之间的跳转
- Android Intent实现Activity之间跳转并传值
- 安卓--使用Intent实现Activity之间传值与跳转
- 利用Intent实现两个Activity之间的跳转
- 使用Intent实现Activity之间传值与跳转
- 使用Intent实现Activity之间传值与跳转
- 利用Intent实现多个Activity之间的跳转
- 我的Android第五章:通过Intent实现活动与活动之间的交互
- Android 四大组件 —— 活动(使用Intent 实现活动的显示跳转)