۱۳۹۴/۰۵/۰۹, ۰۹:۴۸ ب.ظ
این کد رو در اکتیویتی اصلی بنویس
ای کد هار و هم در قسمت prefa
کد پیاچپی:
final SharedPreferences shared = getSharedPreferences("Prefs1", MODE_PRIVATE);
final SharedPreferences.Editor editor = shared.edit();
boolean isFirstRun = shared.getBoolean("FIRSTRUN1", true);
if (isFirstRun){
// Code to run once
final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.dialog);
dialog.setTitle("*با تشکر از انتخاب شما*");
TextView text = (TextView) dialog.findViewById(R.id.textView1);
text.setTypeface(tf);
text.setText("متن مکورد نظر");
Button dialogButton = (Button) dialog.findViewById(R.id.button1);
// if button is clicked, close the custom dialog
dialogButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
editor.putBoolean("FIRSTRUN1", false);
editor.commit();
}
کد پیاچپی:
public class Prefa extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
Boolean b = prefs.getBoolean("FIRSTRUN", true);
}
}
همه آدما برای رسیدن به جایی که هستند از تجربه دیگران استفاده کردند
پس چرا ما از اندک تجربه ای که داریم برای راهنمایی دیگران استفاده نکنیم؟؟
پس چرا ما از اندک تجربه ای که داریم برای راهنمایی دیگران استفاده نکنیم؟؟