导航:首页 > 操作系统 > android显示跳转

android显示跳转

发布时间:2022-09-04 11:29:27

‘壹’ 开发android 怎样实现登录界面的跳转 详细

intent跳转有两种方式,一种是我们常用的显示跳转,还有一种是隐式跳转。
显式方式:Intent aIntent = new Intent(this,XXActivity.class);第一个是你当前Activity的对象,第一个参数是你要跳转Activity的类。这种方式适合在同一个APP中的内部跳转。
隐式方式:Intent aIntent = new Intent("actiionXXXXXXX"),参数为你在AndroidManifest.xml中配置的Actitiy中<intent-filter><action android:name="actionXXXXXXXX"/><intent-filter>

‘贰’ android怎么用intent跳转页面

Android页面跳转Intent使用
在android中,一个页面就是一个activity,在页面跳转中,用到了Intent这个类,其实Intent跳转没什么大不了的,就是调用几个方法,第一个:intent.setAction(“wang.zhe.gui.lai”);当然,里面的”wang.zhe.gui.lai”这个字符串是要在主配置文件中配置的,第二个:intent.setClass(MainActivity.this,SceondViewActivity.class);这个跳转方法是最常用的一种,这两种方法之后,用startActivity(intent);来启动跳转。不过这不是我说的重点,我所要说的是如何传值?一般对于字符串的传值,就是调用intent.putExtra("str",”字符串内容”);来传值,但是要是传一个对象呢?在intent中提供了一个方法,也是 putExtra(),不过,这个是传对象的方法putExtra(String name, Serializable value),是可以传对象的,不过对应的对象要序列化,其实就是实现一个标示接口Serializable,下面将部分源码附上。
这是一个userinfo类
package com.example.regist;

import java.io.Serializable;

public class Userinfo implements Serializable {
String userName;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserPassword() {
return userPassword;
}
public void setUserPassword(String userPassword) {
this.userPassword = userPassword;
}
public String getUserGender() {
return userGender;
}
public void setUserGender(String userGender) {
this.userGender = userGender;
}
public String getUserBathday() {
return userBathday;
}
public void setUserBathday(String userBathday) {
this.userBathday = userBathday;
}
public String getUserLove() {
return userLove;
}
public void setUserLove(String userLove) {
this.userLove = userLove;
}
public String getUserEmail() {
return userEmail;
}
public void setUserEmail(String userEmail) {
this.userEmail = userEmail;
}
String userPassword;
String userGender;
boolean userIsmarry;
public boolean isUserIsmarry() {
return userIsmarry;
}
public void setUserIsmarry(boolean userIsmarry) {
this.userIsmarry = userIsmarry;
}
String userBathday;
String userLove;
String userEmail;
}
可以看出该类实现了Serializable接口。
下面是跳转加传值的部分代码:
Intent intent=new Intent();
intent.setClass(MainActivity.this,SecondviewActivity.class);
intent.putExtra("user",user);//user是实例化之后的对象
startActivity(intent);
下面是第二个界面所对应的类接受传过来的对象的代码
TextView tex=new TextView(this);
Intent intent=getIntent();
Userinfo user=(Userinfo) intent.getSerializableExtra("user");
现在就是一个完整的user对象了,你可以随性而用了。

‘叁’ android 界面跳转怎么控制

下面关于界面跳转的例子来自于android学习手册,如果想看实际运行的例子的话,请去下载,并且可以看源码和文档。android学习手册包含9个章节,108个例子,源码文档随便看,例子都是可交互,可运行, 源码采用android studio目录结构,高亮显示代码,文档都采用文档结构图显示,可以快速定位。360手机助手中下载,图标上有贝壳
android使用,从一个Activity(界面)跳转到另一个Activity时,需要使用到Intent来启动Activity。在Intent使用时,分为显式调用和隐式调用2类,显式调用就是直接调用另一个Activity的class类,隐式调用需要通过调用另一个Activity的action 来启动另一个Activity,详细如下:
Intent在android中的定义为:public Intent (Context packageContext , Class<?> cls);
1、显式调用---直接调用Activity的Class类
例,Activity1调用Activity2
Intent intent = new Intent(this , Activity2.class);
startActivity(intent);
2、隐式调用
Activity1隐式调用Activity2时需要在AndroidManifest.xml文件中配置Activity2的action和category,具体添加下面的代码到Activity2的定义中
<intent-filter>
<action android:name="myaction2"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="mycategory" />
</intent-filter>
接着同样使用intent来启动Activity,代码如下:
Intent intent = new Intent("myaction2");
startActivity(intent);
这样就可以启动Activity2
注:在使用intent隐式调用Activity时会遇到多个Activity的intent-filter中的action和category相同时,这时android会先弹出一个选择界面的窗口,显式要启动的Activity列表,根据用户的选择来启动Activity,如Activity2和Activity3的action和category相同
<Activity android:name=".Activity2">
<intent-filter>
<action android:name="myaction2"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="myCategory" />
</intent-filter>
</Activity>
<Activity android:name=".Activity3">
<intent-filter>
<action android:name="myaction2"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="myCategory" />
</intent-filter>
</Activity>
启动Activity代码如下:
Intent intent = new("action2");
intent.addCategory("myCategory");
startActivity(intent);
这时就会弹出Acvity的选择窗口,选择启动activity2还是activity3

‘肆’ android开发中,像浏览器导航页面那样点击怎么跳转到另一个Activity页面显示出来。怎样传值和接收……

你可以获取对话框的点击事件,比如点击了确定然后你就跳转
AlertDialog.Builder builder = new Builder(CommentActivity.this);
builder.setMessage("确定要跳转吗?");
builder.setTitle("提示");
builder.setPositiveButton("确认",
new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
arg0.dismiss();
这里跳转到你想要去的页面
}
});
builder.setNegativeButton("取消",
new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();

arg0就是该listener的接口啊,通过这个参数就可以关闭对话框。
跳到想去的页面就startIntent就好了,你把那一行中文换成 Intent it = new Intent(this,UserActivity.class); startActivity(it); 当然要跳去哪个页面就你自己决定

AlertDialog.Builder builder = new Builder(CommentActivity.this);
builder.setMessage("确定要跳转吗?");
builder.setTitle("提示");
builder.setPositiveButton("确认",
new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
arg0.dismiss();
Intent it = new Intent(this,UserActivity.class);
startActivity(it);
}
});
builder.setNegativeButton("取消",
new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
还不错,希望你采纳。

‘伍’ 安卓中如何实现页面跳转

‘陆’ Android跳转页面用Intent隐式好还是显示好

各有各的好处……显式的可以从1个Activity跳到另外一个明确的Activity。隐式的就不确定跳到哪个Activity了,但是要对跳转进行描述,描述的内容就是目标Activity的特点,那么系统会自动匹配你需要的目标Activity了。
例如Intent intent = new Intent(Intent.ACTION_CALL); 就是为intent 绑定了ACTION_CALL的动作,就是打电话。

‘柒’ 请问Android大神们,如何实现多个按钮跳转到一个页面,但根据不同的按钮显示不同内容

每个按钮的处理,在标记里传不同的值,如下
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
intent.putExtra("mark", 0);
然后在你跳转后的activity里,调用以下方法即可取到你设置的值
int mark = getIntent().getIntExtra("mark", -1);
根据你不同按钮跳转设置不同的mark值,然后在新开的页面上,获取到mark值,就可以判断是哪个按钮跳转过来的,然后就可以继续你需要的逻辑了

‘捌’ Android怎么跳转到第三方应用的指定界面

界面的转跳都是由Intent来实现的这个Intent,有两种方式,一种叫显示意图,一种叫隐式意图你调用其它APK的界面,那只能通过隐式意图去激活了比如说,你要调用系统的相机拍照,或者调用文件管理器选择文件,这些都是通过隐式意图来实现的

‘玖’ android开发,单击按钮之后跳转到另一个页面

1、首先在一个布局文件(.XML)中绘画了一个跳转按钮(id为btn1):

<Button

android:id="@+id/btn1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="点击跳转" />

2、然后在关联的类中声明一个私有button名称,如:

private Button btn1;

TIPS:在类上会添加:import android.widget.Button;

3、接着在类中onCreate的方法内执行以下操作:

(1)、给btn1赋值,即设置布局文件中的Button按钮id进行关联,如:

btn1 = (Button) findViewById(R.id.btn1);

(2)、给btn1绑定点击事件:

btn1.setOnClickListener(new View.OnClickListener(){

@Override

public void onClick(View v){

}

});

TIPS:在类上会添加:import android.view.View;

(3)、 给bnt1添加点击响应事件:

btn1.setOnClickListener(new View.OnClickListener(){

@Override

public void onClick(View v){

//Intent是一种运行时绑定(run-time binding)机制,它能在程序运行过程中连接两个不同的组件。

//page1为先前已添加的类,并已在AndroidManifest.xml内添加活动事件(<activity android:name="page1"></activity>),在存放资源代码的文件夹下下,

Intent i = new Intent(MainActivity.this , page1.class);

////启动

startActivity(i);

}

});

TIPS:在类上会添加:import android.content.Intent;

4、最后,就可以就可以跳转到下一个页面了。

阅读全文

与android显示跳转相关的资料

热点内容
程序员对老师的感谢 浏览:27
什么app能查看银行卡照片 浏览:22
win7pdf虚拟打印 浏览:323
程序员喜欢的女生条件 浏览:123
阿里云服务器ip搭建教程 浏览:85
解压和拉伸这一动画的原理是什么 浏览:740
tbc战士的命令怒吼 浏览:481
idea快捷键看源码 浏览:976
手机碎屏解压工具 浏览:245
jsonrpcphp使用 浏览:566
网上求职系统源码 浏览:699
pdf数字不显示 浏览:890
convertwordtopdf 浏览:253
程序编译基本单位 浏览:23
python分析图片角度 浏览:64
阿里云服务器能复制数据吗 浏览:562
python拼音转换文字 浏览:563
动画遗传算法 浏览:63
php如何解析xml文件 浏览:702
如何改变appstore的语言 浏览:462