android新建多个java,Java-如何在Android的警报对话框中添加多项选...
我已經在Android應用程序中創建了“同步”菜單.當我們單擊“同步”警報時,打開4個復選框的布局.我想要的是讓它們起作用,例如,當我單擊15分鐘,然后自動取消單擊其他選項時.
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.action_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case R.id.menu_settings:
alertDialog = new AlertDialog.Builder(HomePage.this).create(); //Read Update
LayoutInflater adbInflater = this.getLayoutInflater();
View checkboxLayout = adbInflater.inflate(R.layout.sync_layout, null);
defaultchkbox = (CheckBox)checkboxLayout.findViewById(R.id.defaultchkbox);
after15mint = (CheckBox)checkboxLayout.findViewById(R.id.after15mint);
after30mint = (CheckBox)checkboxLayout.findViewById(R.id.after30mint);
after45mint = (CheckBox)checkboxLayout.findViewById(R.id.after45mint);
alertDialog.setView(checkboxLayout);
alertDialog.setTitle("Synchronization");
alertDialog.setMessage("Choose");
alertDialog.setButton(Dialog.BUTTON_POSITIVE,"Save changes", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
// TODO Auto-generated method stub
boolean checkBoxResult = false;
if(after15mint.isChecked())
{
Toast.makeText(getApplicationContext(), "15 Minute checked", Toast.LENGTH_LONG).show();
checkBoxResult = true;
}
else if(after30mint.isChecked())
{
Toast.makeText(getApplicationContext(), "30 Minute checked", Toast.LENGTH_LONG).show();
checkBoxResult = true;
}
else if(after45mint.isChecked())
{
Toast.makeText(getApplicationContext(), "45 Minute checked", Toast.LENGTH_LONG).show();
checkBoxResult = true;
}
else{
Toast.makeText(getApplicationContext(), "Default", Toast.LENGTH_LONG).show();
}
}
});
alertDialog.setButton(Dialog.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
alertDialog.dismiss();
}
});
alertDialog.show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
但是我對警報中復選框的工作有些困惑.建議將有很大幫助.謝謝. ?
總結
以上是生活随笔為你收集整理的android新建多个java,Java-如何在Android的警报对话框中添加多项选...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 详解TCP协议三次握手四次挥手
- 下一篇: android的图片缩放,Android