




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
【移動(dòng)應(yīng)用開發(fā)技術(shù)】Android中怎么實(shí)現(xiàn)Activity跳轉(zhuǎn)操作
Android中怎么實(shí)現(xiàn)Activity跳轉(zhuǎn)操作,針對這個(gè)問題,這篇文章詳細(xì)介紹了相對應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問題的小伙伴找到更簡單易行的方法。Android中提供一個(gè)叫Intent的類來實(shí)現(xiàn)屏幕之間的跳轉(zhuǎn),下面是一個(gè)簡單的示例:在應(yīng)用中增加一個(gè)Activity(名字為.ForwardTarget),這需要修改AndroidManifest.xml文件,如下:AndroidActivity跳轉(zhuǎn)代碼示例:<
?xml
version="1.0"
encoding="utf-8"?>
<
manifest
xmlns:android="<
A
href="/apk/res/android">/apk/res/android<
/A>"
package="com.ray.forward"
android:versionCode="1"
android:versionName="1.0">
<
application
android:icon="@drawable/icon"
android:label="@string/app_name">
<
activity
android:name=".androidForward"
android:label="@string/app_name">
<
intent-filter>
<
action
android:name="ent.action.MAIN"
/>
<
category
android:name="ent.category.LAUNCHER"
/>
<
/intent-filter>
<
/activity>
<
activity
android:name=".ForwardTarget">
<
/activity>
<
/application>
<
uses-sdk
android:minSdkVersion="3"
/>
<
/manifest>
<
?xml
version="1.0"
encoding="utf-8"?>
<
manifest
xmlns:android="/apk/res/android"
package="com.ray.forward"
android:versionCode="1"
android:versionName="1.0">
<
application
android:icon="@drawable/icon"
android:label="@string/app_name">
<
activity
android:name=".androidForward"
android:label="@string/app_name">
<
intent-filter>
<
action
android:name="ent.action.MAIN"
/>
<
category
android:name="ent.category.LAUNCHER"
/>
<
/intent-filter>
<
/activity>
<
activity
android:name=".ForwardTarget">
<
/activity>
<
/application>
<
uses-sdk
android:minSdkVersion="3"
/>
<
/manifest>
<
?xml
version="1.0"
encoding="utf-8"?>
<
manifest
xmlns:android="<
A
href="/apk/res/android">/apk/res/android<
/A>"
package="com.ray.forward"
android:versionCode="1"
android:versionName="1.0">
<
application
android:icon="@drawable/icon"
android:label="@string/app_name">
<
activity
android:name=".androidForward"
android:label="@string/app_name">
<
intent-filter>
<
action
android:name="ent.action.MAIN"
/>
<
category
android:name="ent.category.LAUNCHER"
/>
<
/intent-filter>
<
/activity>
<
activity
android:name=".ForwardTarget">
<
/activity>
<
/application>
<
uses-sdk
android:minSdkVersion="3"
/>
<
/manifest>
<
?xml
version="1.0"
encoding="utf-8"?>
<
manifest
xmlns:android="/apk/res/android"
package="com.ray.forward"
android:versionCode="1"
android:versionName="1.0">
<
application
android:icon="@drawable/icon"
android:label="@string/app_name">
<
activity
android:name=".androidForward"
android:label="@string/app_name">
<
intent-filter>
<
action
android:name="ent.action.MAIN"
/>
<
category
android:name="ent.category.LAUNCHER"
/>
<
/intent-filter>
<
/activity>
<
activity
android:name=".ForwardTarget">
<
/activity>
<
/application>
<
uses-sdk
android:minSdkVersion="3"
/>
<
/manifest>
然后在layout中的main加入一個(gè)id為leah2的按鈕,另外再創(chuàng)建一個(gè)任意的layout(將要跳轉(zhuǎn)到得layout),我取名為leah2。接下來是兩個(gè)類,一個(gè)是AndroidForward,另一個(gè)是將要跳轉(zhuǎn)到得ForwardTarget,AndroidActivity跳轉(zhuǎn)實(shí)現(xiàn)的代碼分別如下:AndroidForw:
package
com.ray.forward;
import
android.app.Activity;
import
android.content.Intent;
import
android.os.Bundle;
import
android.view.View;
import
android.widget.Button;
public
class
androidForward
extends
Activity
{
/**
Called
when
the
activity
is
first
created.
*/
@Override
public
void
onCreate(Bundle
savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button
btn1
=(Button)findViewById(R.id.leah2);
btn1.setOnClickListener(new
View.OnClickListener(){
@Override
public
void
onClick(View
v)
{
Intent
intent
=
new
Intent();
intent.setClass(androidForward.this,
ForwardTarget.class);
startActivity(intent);
finish();//停止當(dāng)前的Activity,如果不寫,則按返回鍵會跳轉(zhuǎn)回原來的Activity
}
});
}
}
package
com.ray.forward;
import
android.app.Activity;
import
android.content.Intent;
import
android.os.Bundle;
import
android.view.View;
import
android.widget.Button;
public
class
androidForward
extends
Activity
{
/**
Called
when
the
activity
is
first
created.
*/
@Override
public
void
onCreate(Bundle
savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button
btn1
=(Button)findViewById(R.id.leah2);
btn1.setOnClickListener(new
View.OnClickListener(){
@Override
public
void
onClick(View
v)
{
Intent
intent
=
new
Intent();
intent.setClass(androidForward.this,
ForwardTarget.class);
startActivity(intent);
finish();//停止當(dāng)前的Activity,如果不寫,則按返回鍵會跳轉(zhuǎn)回原來的Activity
}
});
}
}
ForwardTarget:
package
com.ray.forward;
import
android.app.Activity;
import
android.os.Bundle;
public
class
ForwardTarget
extends
Activity{
@Override
protected
void
onCreate(Bundle
savedInstanceState)
{
//
TODO
Auto-generated
method
stub
super.onCreate(savedInstanceState);
setContentView(R.layout.leah2);
}
}
AndroidForw:
package
com.ray.forward;
import
android.app.Activity;
import
android.content.Intent;
import
android.os.Bundle;
import
android.view.View;
import
android.widget.Button;
public
class
androidForward
extends
Activity
{
/**
Called
when
the
activity
is
first
created.
*/
@Override
public
void
onCreate(Bundle
savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button
btn1
=(Button)findViewById(R.id.leah2);
btn1.setOnClickListener(new
View.OnClickListener(){
@Override
public
void
onClick(View
v)
{
Intent
intent
=
new
Intent();
intent.setClass(androidForward.this,
ForwardTarget.class);
startActivity(intent);
finish();//停止當(dāng)前的Activity,如果不寫,則按返回鍵會跳轉(zhuǎn)回原來的Activity
}
});
}
}
package
com.ray.forward;
import
android.app.Activity;
import
android.content.Intent;
import
android.os.Bundle;
import
android.view.View;
import
android.widget.Button;
public
class
androidForward
extends
Activity
{
/**
Called
when
the
activity
is
first
created.
*/
@Override
public
void
onCreate(Bundle
savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 跨境支付助力企業(yè)國際市場拓展策略
- 小手拉大手的班級活動(dòng)計(jì)劃
- 提升產(chǎn)出效率的年度目標(biāo)計(jì)劃
- 跨境電商平臺的發(fā)展趨勢及盈利前景
- 水環(huán)境保護(hù)管理規(guī)劃計(jì)劃
- 跨領(lǐng)域財(cái)務(wù)合規(guī)與稅務(wù)優(yōu)化實(shí)踐
- 跨國知識產(chǎn)權(quán)糾紛的庭審策略與挑戰(zhàn)
- 貴州國企招聘2024黎平縣扶貧開發(fā)投資有限責(zé)任公司招聘筆試參考題庫附帶答案詳解
- 跨代財(cái)富傳承家族理財(cái)規(guī)劃的實(shí)踐與思考
- 安徽專版2024中考?xì)v史復(fù)習(xí)方案第三部分中國現(xiàn)代史第17課時(shí)社會主義制度的建立與社會主義建設(shè)的探索提分訓(xùn)練
- COP生產(chǎn)一致性控制計(jì)劃
- 2025年電力人工智能多模態(tài)大模型創(chuàng)新技術(shù)及應(yīng)用報(bào)告-西安交通大學(xué)
- 天津2025年天津市機(jī)關(guān)后勤事務(wù)服務(wù)中心分支機(jī)構(gòu)天津市迎賓館招聘2人筆試歷年參考題庫附帶答案詳解
- 2025年江蘇南京技師學(xué)院招聘工作人員19人高頻重點(diǎn)模擬試卷提升(共500題附帶答案詳解)
- 華東師大版七年級數(shù)學(xué)下冊“第1周周考”
- DBJ50-T-385-2023半柔性復(fù)合路面技術(shù)標(biāo)準(zhǔn)
- 職業(yè)院校教師人工智能素養(yǎng):內(nèi)涵流變、框架構(gòu)建與生成路徑
- 如何在初中數(shù)學(xué)教學(xué)中提升學(xué)生的核心素養(yǎng)
- (完整版)小學(xué)一年級數(shù)學(xué)20以內(nèi)進(jìn)退位加減法(1600道題)計(jì)算卡
- 2025年包頭鐵道職業(yè)技術(shù)學(xué)院高職單招語文2018-2024歷年參考題庫頻考點(diǎn)含答案解析
- 2024年道路運(yùn)輸企業(yè)安全生產(chǎn)管理人員證考試題庫
評論
0/150
提交評論