first time tips
程序员文章站
2022-06-18 16:49:46
...
private boolean isFirstClick(){ SharedPreferences sp = getSharedPreferences(Constants.GET_EFAX_KEY, Context.MODE_PRIVATE); //在Constants类中设定一final value,存储,以便一次点击事件后不再显示 boolean firstclick = sp.getBoolean(Constants.GET_SHAREDPREF_EFAX_KEY, true); return firstclick; } private void setClickFalse(){ SharedPreferences sp = getSharedPreferences(Constants.GET_EFAX_KEY, Context.MODE_PRIVATE); Editor spEditor = sp.edit(); spEditor.putBoolean(Constants.GET_SHAREDPREF_EFAX_KEY, false); spEditor.commit(); }
1.在主layout创建一个layout来承载图片
<LinearLayout android:id="@+id/efax_guide" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/efax_guide" android:orientation="vertical" android:visibility="gone"> //不占空间不显示 </LinearLayout>
2.在oncreat里面调用该layout
mBtn_add_faxPDF = (RadioButton) findViewById(R.id.action_add_fax); //first time tips efaxGuide = (LinearLayout) findViewById(R.id.efax_guide); efaxGuide.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { efaxGuide.setVisibility(View.GONE); v.setVisibility(View.GONE); setClickFalse(); } }); if (isFirstClick()){ Locale locale = getResources().getConfiguration().locale; String language = locale.getLanguage(); if (language.endsWith("en")){ efaxGuide.setBackgroundDrawable(getResources().getDrawable(R.drawable.efax_guide)); } efaxGuide.setVisibility(View.VISIBLE); }
p.s:若first-time-tips不出现,怎可能是布局出现问题,注意不同的parent的覆盖问题
推荐阅读
-
[VB.NET Tips]再谈字符串连接之内置池
-
pandas 快速处理 date_time 日期格式方法
-
【THE LAST TIME】this:call、apply、bind
-
Entity Framework Code First属性映射约定
-
jQuery中:first-child选择器用法实例教程
-
简单学习Python time模块
-
Python编程中time模块的一些关键用法解析
-
python中time.strftime不支持中文,报错UnicodeEncodeError: 'locale' codec can't encode character '\u5e74' in position 2: encoding error
-
Nginx 502 bad gateway和Nginx 504 Gateway Time-out错误解决方法 错误解决办法
-
vue-cli项目中使用公用的提示弹层tips或加载loading组件实例详解