android.中我想软件刚启动就弹出一个“使用说明”的对话框,然后在“设置”里面可以设置
android.中我想软件刚启动就弹出一个“使用说明”的对话框,然后在“设置”里面可以设置下次弹出还是不弹出?用alertdialog能实现么?怎么实现呢?...
android.中我想软件刚启动就弹出一个“使用说明”的对话框,然后在“设置”里面可以设置下次弹出还是不弹出?用alertdialog能实现么?怎么实现呢?
展开
2个回答
展开全部
这是我的一个实现,这个方法在activity 的onCreate中调用即可,这只是实现的一种方法, 还有类似的像把activity设置为dialog模式,利用ViewFlipper 设置多个界面进行切换 等等,android是十分开放的平台,程序员有足够的自由,希望能帮到你,谢谢采纳
private void showDialog()
{
final SharedPreferences sr = getSharedPreferences(FLAG,MODE_PRIVATE);
int iflag = sr.getInt(FLAG, 0);
if(iflag > 0)
{
return ;
}
View view = LayoutInflater.from(A_BaiduZhiDaoActivity.this).inflate(R.layout.dialog, null);
TextView tv = (TextView)view.findViewById(R.id.textView1);
final CheckBox cb = (CheckBox)view.findViewById(R.id.checkBox1);
tv.setText("Please check the box if you don't want this dialog pop up again!");
cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
});
AlertDialog dialog = new AlertDialog.Builder(A_BaiduZhiDaoActivity.this)
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if(cb.isChecked())
{
SharedPreferences.Editor editor = sr.edit();
editor.putInt(FLAG, 1);
editor.commit();
}
}
}).create();
dialog.setView(view);
dialog.setCancelable(false);
dialog.show();
}
private void showDialog()
{
final SharedPreferences sr = getSharedPreferences(FLAG,MODE_PRIVATE);
int iflag = sr.getInt(FLAG, 0);
if(iflag > 0)
{
return ;
}
View view = LayoutInflater.from(A_BaiduZhiDaoActivity.this).inflate(R.layout.dialog, null);
TextView tv = (TextView)view.findViewById(R.id.textView1);
final CheckBox cb = (CheckBox)view.findViewById(R.id.checkBox1);
tv.setText("Please check the box if you don't want this dialog pop up again!");
cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
});
AlertDialog dialog = new AlertDialog.Builder(A_BaiduZhiDaoActivity.this)
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if(cb.isChecked())
{
SharedPreferences.Editor editor = sr.edit();
editor.putInt(FLAG, 1);
editor.commit();
}
}
}).create();
dialog.setView(view);
dialog.setCancelable(false);
dialog.show();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询