Android中設(shè)置只有程序第一次運(yùn)行才顯示的界面實(shí)現(xiàn)思路
更新時(shí)間:2013年06月03日 16:40:58 作者:
如何實(shí)現(xiàn)程序第一次運(yùn)行才顯示的界面,下面是具體的實(shí)現(xiàn)思路及步驟,有類(lèi)似需求的朋友可以參考下哈
程序安裝后第一次啟動(dòng):
啟動(dòng)頁(yè)-->功能介紹頁(yè)-->系統(tǒng)主頁(yè)
以后啟動(dòng):
啟動(dòng)頁(yè)-->系統(tǒng)主頁(yè)
所以在啟動(dòng)頁(yè)中判斷一下就可以了
可以弄一個(gè)文件保存一個(gè)狀態(tài),推薦用SharedPreferences。
1.可以定義一個(gè)變量來(lái)判斷程序是第幾次運(yùn)行,如果是第一次則跳轉(zhuǎn)到引導(dǎo)的Activity,如果不是第一次則執(zhí)行系統(tǒng)主頁(yè)。
判斷系統(tǒng)是第一次運(yùn)行的代碼實(shí)現(xiàn)如下:
在Activity中添加代碼:
使用SharedPreferences來(lái)記錄程序的使用次數(shù)
一下是實(shí)現(xiàn)的代碼:
<SPAN style="FONT-SIZE: 18px"><STRONG>public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
preferences = getSharedPreferences("count",MODE_WORLD_READABLE);
int count = preferences.getInt("count", 0);
//判斷程序與第幾次運(yùn)行,如果是第一次運(yùn)行則跳轉(zhuǎn)到引導(dǎo)頁(yè)面
if (count == 0) {
Intent intent = new Intent();
intent.setClass(getApplicationContext(),LaunchGuideViewActivity.class);
startActivity(intent);
this.finish();
}
Editor editor = preferences.edit();
//存入數(shù)據(jù)
editor.putInt("count", ++count);
//提交修改
editor.commit();</STRONG></SPAN>
啟動(dòng)頁(yè)-->功能介紹頁(yè)-->系統(tǒng)主頁(yè)
以后啟動(dòng):
啟動(dòng)頁(yè)-->系統(tǒng)主頁(yè)
所以在啟動(dòng)頁(yè)中判斷一下就可以了
可以弄一個(gè)文件保存一個(gè)狀態(tài),推薦用SharedPreferences。
1.可以定義一個(gè)變量來(lái)判斷程序是第幾次運(yùn)行,如果是第一次則跳轉(zhuǎn)到引導(dǎo)的Activity,如果不是第一次則執(zhí)行系統(tǒng)主頁(yè)。
判斷系統(tǒng)是第一次運(yùn)行的代碼實(shí)現(xiàn)如下:
在Activity中添加代碼:
使用SharedPreferences來(lái)記錄程序的使用次數(shù)
一下是實(shí)現(xiàn)的代碼:
復(fù)制代碼 代碼如下:
<SPAN style="FONT-SIZE: 18px"><STRONG>public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
preferences = getSharedPreferences("count",MODE_WORLD_READABLE);
int count = preferences.getInt("count", 0);
//判斷程序與第幾次運(yùn)行,如果是第一次運(yùn)行則跳轉(zhuǎn)到引導(dǎo)頁(yè)面
if (count == 0) {
Intent intent = new Intent();
intent.setClass(getApplicationContext(),LaunchGuideViewActivity.class);
startActivity(intent);
this.finish();
}
Editor editor = preferences.edit();
//存入數(shù)據(jù)
editor.putInt("count", ++count);
//提交修改
editor.commit();</STRONG></SPAN>
您可能感興趣的文章:
- Android界面 NotificationManager使用Bitmap做圖標(biāo)
- Android界面設(shè)計(jì)(APP設(shè)計(jì)趨勢(shì) 左側(cè)隱藏菜單右邊顯示content)
- Android筆記之:App應(yīng)用之啟動(dòng)界面SplashActivity的使用
- android 通過(guò)向viewpage中添加listview來(lái)完成滑動(dòng)效果(類(lèi)似于qq滑動(dòng)界面)
- 解析Android開(kāi)發(fā)優(yōu)化之:對(duì)界面UI的優(yōu)化詳解(一)
- android 引導(dǎo)界面的實(shí)現(xiàn)方法
- android開(kāi)發(fā)教程之子線程中更新界面
- Android實(shí)現(xiàn)Activity界面切換添加動(dòng)畫(huà)特效的方法
- Android中刷新界面的二種方法
- Android繪制炫酷引導(dǎo)界面
相關(guān)文章
Android Studio 3.6中新的視圖綁定工具ViewBinding 用法詳解
這篇文章主要介紹了Android Studio 3.6中新的視圖綁定工具ViewBinding 用法,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-03-03android 電話狀態(tài)監(jiān)聽(tīng)(來(lái)電和去電)實(shí)現(xiàn)代碼
從事android開(kāi)發(fā)的朋友們可能電話狀態(tài)監(jiān)聽(tīng)不是很擅長(zhǎng),接下來(lái)將詳細(xì)介紹電話狀態(tài)監(jiān)聽(tīng)功能的實(shí)現(xiàn)步驟,需要了解的朋友可以參考下2012-12-12Android?MaterialButton使用實(shí)例詳解(告別shape、selector)
我們平時(shí)寫(xiě)布局,當(dāng)遇到按鈕需要圓角、或者描邊等,通常的方法是新建一個(gè)xml文件,在shape標(biāo)簽下寫(xiě),然后通過(guò)android:background或setBackground(drawable)設(shè)置,這篇文章主要給大家介紹了關(guān)于Android?MaterialButton使用詳解的相關(guān)資料,需要的朋友可以參考下2022-09-09Android利用動(dòng)畫(huà)實(shí)現(xiàn)背景逐漸變暗
這篇文章主要為大家詳細(xì)介紹了Android利用動(dòng)畫(huà)實(shí)現(xiàn)背景逐漸變暗的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-12-12Android編程布局控件之AbsoluteLayout用法實(shí)例分析
這篇文章主要介紹了Android編程布局控件之AbsoluteLayout用法,結(jié)合實(shí)例形式簡(jiǎn)單分析了Android絕對(duì)布局AbsoluteLayout的使用技巧,需要的朋友可以參考下2015-12-12