當前位置:首頁 » 安卓系統 » 安卓如何彈出一個頁面跳轉頁面

安卓如何彈出一個頁面跳轉頁面

發布時間: 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;
}
}
};
}

熱點內容
玩qq三國要什麼樣的電腦配置 發布:2024-09-20 00:50:57 瀏覽:445
樹莓派zero編譯驅動 發布:2024-09-20 00:50:56 瀏覽:484
上傳文件文件夾找不到 發布:2024-09-20 00:26:32 瀏覽:915
承台箍筋加密區 發布:2024-09-20 00:26:31 瀏覽:228
筆記本什麼配置能流暢運行cf 發布:2024-09-20 00:14:19 瀏覽:952
實測華為編譯器 發布:2024-09-19 23:50:52 瀏覽:822
linux匯總 發布:2024-09-19 23:46:39 瀏覽:453
阿里雲伺服器環境搭建教程 發布:2024-09-19 23:21:58 瀏覽:837
黃色文件夾圖標 發布:2024-09-19 23:19:22 瀏覽:684
mysql資料庫導出導入 發布:2024-09-19 23:00:47 瀏覽:183