android界面跳轉
① 如何指定Android中的瀏覽器跳轉界面
一、啟動android默認瀏覽器
在Android程序中我們可以通過發送隱式Intent來啟動系統默認的瀏覽器。如果手機本身安裝了多個瀏覽器而又沒有設置默認瀏覽器的話,系統將讓用戶選擇使用哪個瀏覽器來打開連接。關於Intent的更多內容請參考《常用Intent》
示例1
Intent intent =newIntent();
intent.setAction("android.intent.action.VIEW");
Uri content_url =Uri.parse("http://www.163.com");
intent.setData(content_url);
startActivity(intent);
這樣子,android就可以調用起手機默認的瀏覽器訪問。
二、啟動指定瀏覽器
在Android程序中我們可以通過發送顯式Intent來啟動指定的瀏覽器。
啟動Android原生瀏覽器
示例2
Intent intent =newIntent();
intent.setAction("android.intent.action.VIEW");
Uri content_url =Uri.parse("http://www.163.com");
intent.setData(content_url);
intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");
startActivity(intent);
只要修改以intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");
中相應的應用程序packagename 和要啟動的activity即可啟動其他瀏覽器來
uc瀏覽器":"com.uc.browser", "com.uc.browser.ActivityUpdate「
opera瀏覽器:"com.opera.mini.android", "com.opera.mini.android.Browser"
qq瀏覽器:"com.tencent.mtt", "com.tencent.mtt.MainActivity"
② android3個界面如何跳轉
首先:
建立要跳轉的Activity,並在清單文件注冊。這里假設注冊的活動為NextActivity
其次
布局(例如main,xml):加個Button,並加上id,如button1
代碼里:
首先聲明Button的變數:private Button bn;(聲明在OnCreat方法外面)
然後綁定:bn=(Button)findViewById(R.id.button1);
然後弄一個監聽,實現匿名內部類
bn.setOnClickListener(new Button.OnClickListener(){//創建監聽
public void onClick(View v) {
Intent inten=new Intent(MainActivity.this,NextActicity.class);
startActivity(intent);
}
});
當然 如果你嫌匿名內部類太麻煩,也可以在按鈕中寫一個android:onClick="onclick"事件來實現
代碼里加
public void onclick(View v){
Intent inten=new Intent(MainActivity.this,NextActicity.class);
startActivity(intent);
}
③ 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:點擊按鈕後跳轉另一頁面
- 01
進入墨刀界面,將需要進行交互動作的界面扔進墨刀中打開。
- 02
在左側左鍵選擇「鏈接區域」,然後拖動到界面中需要進行交互設計的按鈕位置。
- 03
位置確定之後,左鍵點擊區域旁邊的小按鈕,拖動到目標界面中。
- 04
進入預覽模式,點擊剛才設置的區域就能夠進行跳轉了。
⑤ android onitemclick實現界面跳轉
你這是listView的item點擊事件吧,
listView.setOnItemClickListener(new
AdapterView.OnItemClickListener()
{
@Override
public
void
onItemClick(AdapterView
?
parent,
View
view,
int
position,
long
id)
{
Intent
intent
=
new
Intent("當前activity.this","需要跳轉的activity.class")
intent.setAction("傳過去的數據");
startActivity(intent);
}
});
這樣就可以實現點擊每一個item就能實現跳轉
⑥ 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 怎樣實現登錄界面的跳轉 詳細
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應用程序如何實現界面跳轉
你先寫一個xml文件 內容是<Button xmlns:android="http://scehmas.android.com/apk/res/android" android:layout_widht="wrap_content" android:layout_height="wrap_content" android:text="按鈕" android:id="@+/btn"/>
然後再第一個activity 中通過findViewById()得到這個button button.setOnClickListener(new OnClickListener(){
public void onClick(View view){
Intent intent=new Intent();
intent.setCass(Activity1.this,activity2.class)
startAtivity(intent);
});
ok 這樣就行了 純手敲望採納。
⑨ android頁面跳轉的幾種方式
android頁面跳轉的話,現在更多是流行使用fragment來進行切換,還有就是intent來進行跳轉。
⑩ 安卓中如何實現頁面跳轉
安卓實現頁面跳轉及傳遞參數教程:
用類名跳轉
Intent負責對應用中一次操作的動作、動作涉及數據、附加數據進行描述,Android則根據此Intent的描述, 負責找到對應的組件,將 Intent傳遞給調用的組件,並完成組件的調用。Intent在這里起著實現調用者與被調用者之間的解耦作用。
Intent傳遞過程中,要找到目標消費者(另一個Activity,IntentReceiver或Service),也就是Intent的響應者。
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跳轉實現
使用Action跳轉,如果有一個程序的 AndroidManifest.xml中的某一個Activity的IntentFilter段中定義了包含了相同的Action那麼這個Intent 就與這個目標Action匹配。如果這個IntentFilter段中沒有定義 Type,Category,那麼這個 Activity就匹配了。但是如果手機中有兩個以上的程序匹配,那麼就會彈出一個對話可框來提示說明。
Action的值在Android中有很多預定義,如果想直接轉到你自己定義的Intent接收者,可以在接收者的 IntentFilter中加入一個自定義的Action值(同時要設定 Category值為"android.intent.category.DEFAULT"),在Intent中設定該值為Intent的 Action,就直接能跳轉到自己的Intent接收者中。因為這個Action在系統中是唯一的。
data/type,可以用Uri來做為data,比如Uri uri = Uri.parse(http://www.google.com);
Intent i = new Intent(Intent.ACTION_VIEW,uri);手機的Intent分發過程中,會根據http://www.google.com 的scheme判斷出數據類型type
手機的Brower則能匹配它,在Brower的Manifest.xml中的IntenFilter中首先有ACTION_VIEW Action,也能處理http:的type。
至於分類Category,一般不要去在Intent中設置它,如果寫Intent的接收者,就在Manifest.xml的 Activity的 IntentFilter中包含android.category.DEFAULT,這樣所有不設置 Category(Intent.addCategory(String c);)的Intent都會與這個Category匹配。
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>