Android的设置开机画面(活动),如iPhone第一部分

编程入门 行业动态 更新时间:2024-10-08 06:19:06
本文介绍了Android的设置开机画面(活动),如iPhone第一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有我的三个图像,我希望他们能够出现在像泼视图第一个布局XML使他们能只有一次,即该活动被视为只会调用一次,当应用程序获取的安装,或者应用程序获取一个新的更新否则应用程序应该始终从第二个开始的活动,我不知道我应该如何开始的:

I have three images with me and i want them to appear on first layout xml like a splash view so that they can be viewed only once i.e that activity will be called only once when app get's installed or if app get's a new update otherwise app should always start from the Second activity, i don't know how should i begin with this :

任何一个可以告诉我任何想法如何可以做到这一点。

Can any one tell me any idea how this can be done.

要显示启动了一次。

这个问题的下一步的部分是here

Next part of this question is here

编码将大大AP preciated。

Coding will be much appreciated.

推荐答案

保存在preferences一个标志,当你启动应用程序,您已经做了欢迎屏幕之后的东西。检查这个标志告诉你的欢迎屏幕前。如果标志为present(换句话说,如果这不是第一次了),没有表现出来。

In your activity: SharedPreferences mPrefs; final String welcomeScreenShownPref = "welcomeScreenShown"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mPrefs = PreferenceManager.getDefaultSharedPreferences(this); // second argument is the default to use if the preference can't be found Boolean welcomeScreenShown = mPrefs.getBoolean(welcomeScreenShownPref, false); if (!welcomeScreenShown) { // here you can launch another activity if you like // the code below will display a popup String whatsNewTitle = getResources().getString(R.string.whatsNewTitle); String whatsNewText = getResources().getString(R.string.whatsNewText); new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle(whatsNewTitle).setMessage(whatsNewText).setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).show(); SharedPreferences.Editor editor = mPrefs.edit(); editor.putBoolean(welcomeScreenShownPref, true); editormit(); // Very important to save the preference } }

更多推荐

Android的设置开机画面(活动),如iPhone第一部分

本文发布于:2023-10-31 06:55:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545350.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:第一部分   开机画面   Android   iPhone

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!