android弹出进度条对话框的方法
实际代码是做和做FM闹钟相关功能,收藏防止以后查阅
[java] new AlertDialog.Builder(this)
.setTitle(getString(R.string.info))
.setMessage(getString(R.string.auto_search_confirm))
.setPositiveButton(android.R.string.ok,
new DialogInte易做图ce.OnClickListener() {
public void onClick(DialogInte易做图ce dialog, int w) {
dialog.dismiss();
searchProcess();
}
private void searchProcess() {
LinearLayout myLayout;
LayoutInflater layoutInflater;
AlertDialog.Builder dialogBuilder;
myLayout = new LinearLayout(SetAlarm.this);
layoutInflater=(LayoutInflater) getSystemService(SetAlarm.this.LAYOUT_INFLATER_SERVICE);
myLayout=(LinearLayout) layoutInflater.inflate(R.layout.progress_dialog, null);
progressBar=(ProgressBar)myLayout.findViewById(R.id.progressBar);
progressBar.setMax(205);
dialogBuilder = new AlertDialog.Builder(SetAlarm.this);
dialogBuilder.setView(myLayout);
dialogBuilder.setMessage(SetAlarm.this.getString(R.string.channel_searching));
dialog = dialogBuilder.show();
dialog.setCancelable(false);
if (localAudioManager != null && localAudioManager.isWiredHeadsetOn()) {
registerReceiver(searchBroadcast, new IntentFilter(SEARCH_DONE));
registerReceiver(searchBroadcast, new IntentFilter(SET_PROGRESS));
mFMAlarmPref.searchChannel();
} else {
if(dialog != null && dialog.isShowing())
{
dialog.dismiss();
}
Toast toast = Toast.makeText(SetAlarm.this, SetAlarm.this.getString(R.string.plug_in_headset), Toast.LENGTH_LONG);
ToastMaster.setToast(toast);
toast.show();
}
}
})
.setNegativeButton(android.R.string.cancel,
new DialogInte易做图ce.OnClickListener() {
@Override
public void onClick(DialogInte易做图ce dialog,
int which) {
mFMRingState.setChecked(false);
mAlarmPref.setEnabled(true);
dialog.dismiss();
}
}).show();
new AlertDialog.Builder(this)
.setTitle(getString(R.string.info))
.setMessage(getString(R.string.auto_search_confirm))
.setPositiveButton(android.R.string.ok,
new DialogInte易做图ce.OnClickListener() {
public void onClick(DialogInte易做图ce dialog, int w) {
dialog.dismiss();
searchProcess();
}
private void searchProcess() {
LinearLayout myLayout;
LayoutInflater layoutInflater;
AlertDialog.Builder dialogBuilder;
myLayout = new LinearLayout(SetAlarm.this);
layoutInflater=(LayoutInflater) getSystemService(SetAlarm.this.LAYOUT_INFLATER_SERVICE);
myLayout=(LinearLayout) layoutInflater.inflate(R.layout.progress_dialog, null);
progressBar=(ProgressBar)myLayout.findViewById(R.id.progressBar);
progressBar.setMax(205);
dialogBuilder = new AlertDialog.Builder(SetAlarm.this);
dialogBuilder.setView(myLayout);
dialogBuilder.setMessage(SetAlarm.this.getString(R.string.channel_searching));
dialog = dialogBuilder.show();
dialog.setCancelable(false);
if (localAudioManager != null && localAudioManager.isWiredHeadsetOn()) {
registerReceiver(searchBroadcast, new IntentFilter(SEARCH_DONE));
registerReceiver(searchBroadcast, new IntentFilter(SET_PROGRESS));
mFMAlarmPref.searchChannel();
} else {
if(dialog != null && dialog.isShowing())
{
dialog.dismiss();
}
Toast toast = Toast.makeText(SetAlarm.this, SetAlarm.this.getString(R.string.plug_in_headset), Toast.LENGTH_LONG);
ToastMaster.setToast(toast);
toast.show();
}
}
})
.setNegativeButton(android.R.string.cancel,
new DialogInte易做图ce.OnClickListener() {
@Override
public void onClick(DialogInte易做图ce dialog,
int which) {
mFMRingState.setChecked(false);
mAlarmPref.setEnabled(true);
补充:移动开发 , Android ,