Intent实现跳转
来源:互联网 发布:无主之地2无网络连接 编辑:程序博客网 时间:2024/06/05 02:30
1.activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" >
<TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/firstprompt" />
<Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView1" android:layout_below="@+id/textView1" android:layout_marginTop="22dp" android:text="@string/change" />
</RelativeLayout>
2.activity_second.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".SecondActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/secondeprompt" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginTop="20dp"
android:text="@string/change"/>
</RelativeLayout>
3.MainActivity.java
package cn.bzu.intent.activityjump;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
private Button change;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
change=(Button) this.findViewById(R.id.button1);
change.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent();
intent.setClass(MainActivity.this, SecondActivity.class);
startActivity(intent);
finish();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
4.
package cn.bzu.intent.activityjump;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class SecondActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.second, menu);
return true;
}
}
- Intent实现跳转
- Intent 跳转的实现
- Intent实现页面跳转
- Intent实现页面跳转
- Intent实现页间面跳转
- Intent实现页面跳转
- Intent 实现Activity跳转
- Intent实现页面跳转
- Intent实现跳转
- Intent实现activity跳转
- Intent实现Activity跳转
- 使用Intent实现页面跳转
- 使用Intent实现页面跳转
- 使用Intent实现Activity跳转
- 使用Intent实现页面跳转
- 使用Intent实现页面跳转
- Intent实现页面的跳转
- Intent实现Activity的跳转
- Win32编程的demo,在另一台机器上不窗口显示不出来
- Eclipse、Tomcat环境配置及web应用发布的几种方式
- u-boot.lds 分析 .
- JavaScript访问弹出窗口的弹出窗口
- cassandra (2)Understanding the Architecture【Architecture in brief】
- Intent实现跳转
- android修行之路----经典书籍
- 小程序(三)数组排序问题1奇偶数组排序
- Maven常用命令
- Linux下的ELF文件格式简介 .
- 导致flash屏幕重绘的几种方式及避免重绘的方法
- android学习网站(持续更新)
- session和cookie的辨析
- Steve Yegge:Google面试秘籍