android中如何设置点击button页面跳转
来源:互联网 发布:h3c mac地址绑定 编辑:程序博客网 时间:2024/04/29 08:14
弄了这么多天终于能跳转了,哭瞎T T
首先在在AndroidManifest.xml里配置(这个得先在src里新建一个OtherActivity.java)
<!-- 添加第二个activity -->
<activity android:name=".OtherActivity" android:label="other Activity"></activity>
在第一个main layout里面配置一个跳转按钮
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="打开otheractivity"
android:id="@+id/button" //id名字记住
/>
配置第二个layout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="other activiy"
/>
</LinearLayout>
待跳转页面的activity,与第二个layout结合.代码如下
public class OtherActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setContentView(R.layout.other);
}
}
对主activity配置.点击button可以跳转到第二个页面
(会有很多问题,如果使用Eclipse的话,可以使用快捷键【Ctrl+Shift+o】 ,自动添加相应的import。)
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
Button button = (Button)this.findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// 打开另一个activity,通过意图,意图作用是激活其他组件
Intent intent = new Intent();
intent.setClass(MainActivityActivity.this, OtherActivity.class);
//发送意图.将意图发送给android系统,系统根据意图来激活组件
startActivity(intent);
}
});
}
- android中如何设置点击button页面跳转
- android点击button后的页面跳转
- Android-ListView中添加Button或者可点击TextView进行页面跳转
- android---AppWidget(在home页面点击Button跳转)
- Android中点击ViewPager实现跳转页面
- 在项目中,点击“删除”按钮后,跳转到哪个页面?又该如何设置?
- Button点击两次实现页面跳转
- js点击button跳转到另一个页面
- 如何在android中设置一个返回button,点击后返回上一个activity?
- android 如何实现点击button跳转本activity中;而且本activity中的图片变成了另一图片
- Android中点击Button
- Android-设置Button不可点击
- ASP.NET中Button按钮,需点击两次,才能够页面跳转。原因与解决办法。
- Android跳转设置页面
- Android中点击TextView文本链接跳转到指定页面
- js点击button按钮跳转到页面代码
- Button点击事件实现页面跳转的两种方法
- andorid adapteritem 上面的button点击时跳转页面
- 无源码调试dex
- Android学习——定时执行,线程,线程池
- HDU 1247 Hat’s Words // Trie, 枚举
- 动态规划之最长公共子序列(LCS)
- Nginx负载均衡配置
- android中如何设置点击button页面跳转
- 【鸟哥的linux私房菜-学习笔记】文件系统管理
- codeforces #39E
- size class 初探
- 字符串与Date日期的相互转换
- Android 通过 IMSI 判断手机运营商
- 想法与环境
- 浏览器前缀的Sass写法
- 图像分割算法:概述及常用边缘检测算法