欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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的覆盖问题

相关标签: layout