当前位置:首页 » 安卓系统 » 安卓如何弹出一个页面跳转页面

安卓如何弹出一个页面跳转页面

发布时间: 2022-01-11 12:46:29

A. 安卓界面跳转问题

text1.setOnClickListener(new TextView.OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(MainActivity.this, choosepic.class);
startActivity(intent);
}
});
看出来了么

B. android中如何设置点击button页面跳转

button触发事件,
然后用Intent就可以了
Intent
intent
=
new
Intent(本activity.this,要跳转的activity.class);
startActivity(intent);

C. android 开发中点击弹出对话框中的按钮进行页面跳转如何实现

在按钮的点击事件中,用intent跳到下一个activity

D. 安卓中如何实现页面跳转

  • 安卓实现页面跳转及传递参数教程:

  • 用类名跳转

    1. Intent负责对应用中一次操作的动作、动作涉及数据、附加数据进行描述,Android则根据此Intent的描述, 负责找到对应的组件,将 Intent传递给调用的组件,并完成组件的调用。Intent在这里起着实现调用者与被调用者之间的解耦作用。

    2. Intent传递过程中,要找到目标消费者(另一个Activity,IntentReceiver或Service),也就是Intent的响应者。

      java">Java代码packagecom.Android;

      importandroid.app.Activity;
      importandroid.content.Intent;
      importandroid.os.Bundle;
      importandroid.view.View;
      importandroid.view.View.OnClickListener;

      {
      @Override
      publicvoidonCreate(BundlesavedInstanceState){
      super.onCreate(savedInstanceState);
      setContentView(R.layout.formstuff);

      finalImageButtonbutton=(ImageButton)findViewById(R.id.android_button);
      button.setOnClickListener(newOnClickListener(){
      publicvoidonClick(Viewv){
      //用类名跳转,需要在AndroidManifest.xml中申明activity
      Intentintent=newIntent(FormStuff.this,HelloTabWidget.class);
      startActivity(intent);
      }
      });

      }
      复制代码Xml代码<?xmlversion="1.0"encoding="utf-8"?>
      <manifestxmlns:android="http://schemas.android.com/apk/res/android"
      package="com.Android"android:versionCode="1"android:versionName="1.0">

      <applicationandroid:icon="@drawable/icon"android:theme="@android:style/Theme.NoTitleBar">
      <activityandroid:name=".FormStuff"android:label="@string/app_name">
      <intent-filter>
      <actionandroid:name="android.intent.action.MAIN"/>
      <categoryandroid:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
      </activity>
      <!--申明activity-->
      <activityandroid:name="HelloTabWidget"></activity>
      </application>
      <uses-sdkandroid:minSdkVersion="4"/>
      </manifest>


  • 使用Action跳转实现

    1. 使用Action跳转,如果有一个程序的 AndroidManifest.xml中的某一个Activity的IntentFilter段中定义了包含了相同的Action那么这个Intent 就与这个目标Action匹配。如果这个IntentFilter段中没有定义 Type,Category,那么这个 Activity就匹配了。但是如果手机中有两个以上的程序匹配,那么就会弹出一个对话可框来提示说明。

      1. Action的值在Android中有很多预定义,如果想直接转到你自己定义的Intent接收者,可以在接收者的 IntentFilter中加入一个自定义的Action值(同时要设定 Category值为"android.intent.category.DEFAULT"),在Intent中设定该值为Intent的 Action,就直接能跳转到自己的Intent接收者中。因为这个Action在系统中是唯一的。

    2. data/type,可以用Uri来做为data,比如Uri uri = Uri.parse(http://www.google.com);

      1. Intent i = new Intent(Intent.ACTION_VIEW,uri);手机的Intent分发过程中,会根据http://www.google.com 的scheme判断出数据类型type

      2. 手机的Brower则能匹配它,在Brower的Manifest.xml中的IntenFilter中首先有ACTION_VIEW Action,也能处理http:的type。

    3. 至于分类Category,一般不要去在Intent中设置它,如果写Intent的接收者,就在Manifest.xml的 Activity的 IntentFilter中包含android.category.DEFAULT,这样所有不设置 Category(Intent.addCategory(String c);)的Intent都会与这个Category匹配。

    4. extras(附加信息),是其它所有附加信息的集合。使用extras可以为组件提供扩展信息,比如,如果要执行“发送电子邮件”这个动作,可以将电子邮件的标题、正文等保存在extras里,传给电子邮件发送组件。

      Java代码packagecom.android.edit_text;

      importandroid.app.Activity;
      importandroid.content.Intent;
      importandroid.os.Bundle;
      importandroid.view.KeyEvent;
      importandroid.view.View;
      importandroid.widget.EditText;

      {

      privateTextViewm_TextView;
      privateEditTextm_EditText;


      @Override
      publicvoidonCreate(BundlesavedInstanceState){
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);

      m_EditText=(EditText)this.findViewById(R.id.EditText01);
      m_EditText.setOnKeyListener(editTextKeyListener);
      }

      privateEditText.=newEditText.OnKeyListener(){

      @Override
      publicbooleanonKey(Viewarg0,intarg1,KeyEventarg2){

      //action跳转,需要在AndroidManifest.xml中配置action
      Intenti=newIntent("android.intent.action.mydialog");
      MyEditText.this.startActivity(i);

      returnfalse;
      }
      };
      }
      复制代码Xml代码<?xmlversion="1.0"encoding="utf-8"?>
      <manifestxmlns:android="http://schemas.android.com/apk/res/android"
      package="com.android.edit_text"android:versionCode="1"
      android:versionName="1.0">
      <applicationandroid:icon="@drawable/icon"android:label="@string/app_name">
      <activityandroid:name=".MyEditText"android:label="@string/app_name">
      <intent-filter>
      <actionandroid:name="android.intent.action.MAIN"/>
      <categoryandroid:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
      </activity>
      <!--配置跳转activity-->
      <activityandroid:name="com.android.dialog.MyDialog">
      <intent-filter>
      <!--配置action路径-->
      <actionandroid:name="android.intent.action.mydialog"/>
      <categoryandroid:name="android.intent.category.DEFAULT"/>
      </intent-filter>
      </activity>
      </application>
      <uses-sdkandroid:minSdkVersion="7"/>
      </manifest>

E. android开发如何点击一个文本框跳转到网页

<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:autoLink="web"
android:background="@color/state_item_pressed"
android:text="跳转到web;www..com"/>

F. 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、最后,就可以就可以跳转到下一个页面了。

G. 求一段单击按钮,从一个界面跳转到另一个界面的android的代码

您好,是这样的:
package ui.one.test;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Ui3Activity extends Activity {

private Button button1;
private Button button2;
private Button button3;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//获取控件
button1 = (Button)this.findViewById(R.id.button1);
button2 = (Button)this.findViewById(R.id.button2);
button3 = (Button)this.findViewById(R.id.button3);
//注册点击事件
button1.setOnClickListener(listener);
button2.setOnClickListener(listener);
button3.setOnClickListener(listener);
}

private OnClickListener listener = new OnClickListener()
{
public void onClick(View view)
{
// TODO Auto-generated method stub
Button button = (Button) view;//强制转换类型
switch (button.getId())
{
case R.id.button1: {
Intent intent = new Intent();
intent.setClass(Ui3Activity.this, Ui3son1Activity.class);
startActivity(intent);
}break;
case R.id.button2: {
Intent intent = new Intent();
intent.setClass(Ui3Activity.this, Ui3son2Activity.class);
startActivity(intent);
}break;
case R.id.button3: {
Intent intent = new Intent();
intent.setClass(Ui3Activity.this, Ui3son2Activity.class);
startActivity(intent);
}break;
}
}
};
}

热点内容
pythonshutdown 发布:2024-09-19 10:04:07 浏览:561
ftp连接工具安装 发布:2024-09-19 09:56:57 浏览:192
nba2kol2安卓手游怎么下 发布:2024-09-19 09:55:28 浏览:11
服务器换位置了ip地址怎么换 发布:2024-09-19 09:33:50 浏览:798
javarest 发布:2024-09-19 09:28:43 浏览:753
密码子的原料是什么 发布:2024-09-19 09:11:42 浏览:348
半夜编程 发布:2024-09-19 09:11:36 浏览:104
海康威视存储卡质量如何 发布:2024-09-19 08:55:35 浏览:941
python3默认安装路径 发布:2024-09-19 08:50:22 浏览:517
环卫视频拍摄脚本 发布:2024-09-19 08:35:44 浏览:419