本文整理匯總了Java中android.support.v7.app.AppCompatDialog.setCancelable方法的典型用法代碼示例。如果您正苦於以下問題:Java AppCompatDialog.setCancelable方法的具體用法?Java AppCompatDialog.setCancelable怎麽用?Java AppCompatDialog.setCancelable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.app.AppCompatDialog
的用法示例。
在下文中一共展示了AppCompatDialog.setCancelable方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showProgressbar
import android.support.v7.app.AppCompatDialog; //導入方法依賴的package包/類
public AppCompatDialog showProgressbar(Activity activity, long timeout, boolean cancelable) {
final AppCompatDialog dialog = new AppCompatDialog(activity);
dialog.setContentView(R.layout.dialog_progress);
dialog.setCancelable(cancelable);
dialog.setTitle("Progressing...");
ProgressBar progressBar = (ProgressBar) dialog.findViewById(R.id.progress);
if (timeout > 0) {
Handler handler = new Handler(activity.getMainLooper());
handler.postDelayed(new Runnable() {
@Override
public void run() {
dialog.cancel();
dialog.dismiss();
}
}, timeout);
dialog.show();
} else {
dialog.show();
}
return dialog;
}
示例2: rescan
import android.support.v7.app.AppCompatDialog; //導入方法依賴的package包/類
private void rescan(){
ConnectivityManager connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (mWifi.isConnected() && mWifi.isAvailable()){
AppCompatDialog dialog = new AppCompatDialog(this);
dialog.setTitle(R.string.scanning);
dialog.setCancelable(false);
dialog.show();
AsyncScan scan = new AsyncScan(dialog, getString(R.string.scanning_your_network));
scan.execute(adapter);
}else {
Toast.makeText(this, getString(R.string.not_connected_error), Toast.LENGTH_LONG).show();
}
}
示例3: showWarningDialog
import android.support.v7.app.AppCompatDialog; //導入方法依賴的package包/類
/**
* Shows the initial warning dialog
*/
void showWarningDialog() {
final AppCompatDialog d = new AppCompatDialog(this);
d.setTitle("Warning");
d.setCancelable(false);
d.setContentView(R.layout.warningdialog);
final CheckBox c = (CheckBox) d.findViewById(R.id.c);
final Button b = (Button) d.findViewById(R.id.b);
c.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
b.setText(checked ? android.R.string.ok : android.R.string.cancel);
}
});
b.setText(android.R.string.cancel);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (c.isChecked()) {
getSharedPreferences("settings", MODE_PRIVATE).edit()
.putBoolean("warningRead", true).commit();
d.dismiss();
} else {
d.dismiss();
finish();
}
}
});
d.show();
}