Java Code Examples for android.support.v7.app.AlertDialog

The following examples show how to use android.support.v7.app.AlertDialog. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
protected void requestPermissions(int title, int message, final int requestCode, final String... permissions) {
    boolean shouldShowDialog = false;
    for (String permission : permissions) {
        if (ActivityCompat.shouldShowRequestPermissionRationale(this, permission)) {
            shouldShowDialog = true;
            break;
        }
    }

    if (shouldShowDialog) {
        final Activity activity = this;
        AlertDialog builder = new AlertDialog.Builder(this).setTitle(title)
                .setMessage(message)
                .setPositiveButton(android.R.string.ok, null).create();
        builder.setCanceledOnTouchOutside(false);
        builder.show();

        builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                ActivityCompat.requestPermissions(activity, permissions, requestCode);
            }
        });
    } else
        ActivityCompat.requestPermissions(this, permissions, requestCode);
}
 
Example 2
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());

    final View alertDialogView = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_dialog_about, null);

    final AlertDialog alertDialog = alertDialogBuilder.setView(alertDialogView).setPositiveButton(getString(R.string.ok), null).show();
    alertDialog.setCanceledOnTouchOutside(false);

    alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
                dismiss();
        }
    });

    return alertDialog;
}
 
Example 3
private void showMLSLimitedServiceDisclaimer() {
    int initialGuideVersion = PreferenceManager.getDefaultSharedPreferences(getBaseContext())
            .getInt(Constants.APP_INITIAL_GUIDE_VERSION, 0);
    if (initialGuideVersion != 4) {
        return;
    }
    final Context localContext = getBaseContext();
    final AlertDialog.Builder settingsAlert = new AlertDialog.Builder(MainActivity.this);
    settingsAlert.setTitle(R.string.alertDialog_mls_service_title);
    settingsAlert.setMessage(R.string.alertDialog_mls_service_message);
    settingsAlert.setNeutralButton(R.string.alertDialog_battery_optimization_proceed,
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    SharedPreferences.Editor preferences = PreferenceManager.getDefaultSharedPreferences(localContext).edit();
                    preferences.putInt(Constants.APP_INITIAL_GUIDE_VERSION, 5);
                    preferences.apply();
                    checkAndShowInitialGuide();
                }
            });
    settingsAlert.show();
}
 
Example 4
Source Project: InstaTag   Source File: HomeFragment.java    License: Apache License 2.0 6 votes vote down vote up
public void showDeleteAllPhotosAlertDialog() {
    AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    alert.setTitle(getString(R.string.remove_all_tagged_posts));
    alert.setMessage(getString(R.string.are_you_sure_you_want_to_delete_all_posts));
    alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            InstaTagApplication.getInstance().savePhotos(new ArrayList<Photo>());
            photos.clear();
            photoAdapter.notifyDataSetChanged();
            showEmptyContainer();
        }
    });
    alert.setNegativeButton(getString(R.string.cancel), null);
    alert.show();
}
 
Example 5
Source Project: CatchPiggy   Source File: PigstyMode.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void initExitDialog(OnExitedListener listener) {
    OnClickListener onClickListener = v -> {
        switch (v.getId()) {
            case R.id.continue_game_btn:
                mExitDialog.dismiss();
                break;
            case R.id.back_to_menu_btn:
                mExitDialog.dismiss();
                exitNow();
                listener.onExited();
                break;
            default:
                break;
        }
    };
    View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_exit_view, null, false);
    dialogView.findViewById(R.id.continue_game_btn).setOnClickListener(onClickListener);
    dialogView.findViewById(R.id.back_to_menu_btn).setOnClickListener(onClickListener);
    mExitDialog = new AlertDialog.Builder(getContext(), R.style.DialogTheme).setView(dialogView).create();
}
 
Example 6
Source Project: Companion-For-PUBG-Android   Source File: ItemFragment.java    License: MIT License 6 votes vote down vote up
private void showDisclaimerForFirstTime() {
    final SharedPreferences preferences = getActivity().getSharedPreferences("temp", Context.MODE_PRIVATE);
    final String hasShown = "hasShown";
    if (preferences.getBoolean(hasShown, false)) {
        return;
    }

    AlertDialog alertDialog = new AlertDialog.Builder(getActivity())
            .setTitle("This is still in beta!")
            .setMessage("Data is not yet finished nor complete. Please help us via Github. Links available in the drawer.")
            .setPositiveButton("Ok no problem!", null)
            .show();
    alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            preferences.edit().putBoolean(hasShown, true).apply();
        }
    });
}
 
Example 7
Source Project: Leisure   Source File: MainActivity.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
private void showSearchDialog(){
    final EditText editText = new EditText(this);
    editText.setGravity(Gravity.CENTER);
    editText.setSingleLine();
    new AlertDialog.Builder(this)
            .setTitle(getString(R.string.text_search_books))
            .setIcon(R.mipmap.ic_search)
            .setView(editText)
            .setPositiveButton(getString(R.string.text_ok), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if(Utils.hasString(editText.getText().toString())){
                        Intent intent = new Intent(MainActivity.this,SearchBooksActivity.class);
                        Bundle bundle = new Bundle();
                        bundle.putString(getString(R.string.id_search_text),editText.getText().toString());
                        intent.putExtras(bundle);
                        startActivity(intent);
                    }
                }
            }).show();
}
 
Example 8
private ColorPickerDialogBuilder(Context context, int theme) {
	defaultMargin = getDimensionAsPx(context, R.dimen.default_slider_margin);
	final int dialogMarginBetweenTitle = getDimensionAsPx(context, R.dimen.default_slider_margin_btw_title);

	builder = new AlertDialog.Builder(context, theme);
	pickerContainer = new LinearLayout(context);
	pickerContainer.setOrientation(LinearLayout.VERTICAL);
	pickerContainer.setGravity(Gravity.CENTER_HORIZONTAL);
	pickerContainer.setPadding(defaultMargin, dialogMarginBetweenTitle, defaultMargin, defaultMargin);

	LinearLayout.LayoutParams layoutParamsForColorPickerView = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
	layoutParamsForColorPickerView.weight = 1;
	colorPickerView = new ColorPickerView(context);

	pickerContainer.addView(colorPickerView, layoutParamsForColorPickerView);

	builder.setView(pickerContainer);
}
 
Example 9
private void askForOSMUsername() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("OpenStreetMap User Name");
    builder.setMessage("Please enter your OpenStreetMap user name.");
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    builder.setView(input);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String userName = input.getText().toString();
            SharedPreferences.Editor editor = userNamePref.edit();
            editor.putString("userName", userName);
            editor.apply();
            if (TagEdit.saveToODKCollect(userName)) {
                setResult(Activity.RESULT_OK);
                finish();
            }
        }
    });
    builder.show();
}
 
Example 10
Source Project: iroha-android   Source File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void showError(Throwable throwable) {
    AlertDialog alertDialog = new AlertDialog.Builder(this)
            .setTitle(getString(R.string.error_dialog_title))
            .setMessage(
                    throwable.getCause() instanceof ConnectException ?
                            getString(R.string.general_error) :
                            throwable.getLocalizedMessage()
            )
            .setCancelable(true)
            .setPositiveButton(android.R.string.ok, (dialog, which) -> {
                if (throwable.getCause() instanceof ConnectException) {
                    //  finish();
                }
            })
            .create();
    alertDialog.show();
}
 
Example 11
Source Project: PKUCourses   Source File: Utils.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void showPrivacyPolicyDialog(Context context) {

        AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AlertDialogTheme);

        TextView msg = new TextView(context);
        msg.setText(Html.fromHtml(Utils.privacyPolicy));
        msg.setMovementMethod(LinkMovementMethod.getInstance());
        builder.setView(msg);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
        lp.setMargins(50, 50, 50, 50);
        msg.setLayoutParams(lp);

        ScrollView ll = new ScrollView(context);
        ll.addView(msg);

        builder.setView(ll);
//                builder.setMessage("声明:\n所有用户的密码将不会被开发者获取,如仍有疑问,可访问\"https://github.com/cbwang2016/PKUCourses\"查看源码,谢谢您的信任。");
        builder.setPositiveButton("好的", null).create().show();
    }
 
Example 12
private void onWifiDisabled() {
    log.d("Wi-Fi disabled; prompting user");
    new AlertDialog.Builder(this)
            .setTitle(R.string.wifi_required)
            .setPositiveButton(R.string.enable_wifi, (dialog, which) -> {
                dialog.dismiss();
                log.i("Enabling Wi-Fi at the user's request.");
                wifiFacade.setWifiEnabled(true);
                wifiListFragment.scanAsync();
            })
            .setNegativeButton(R.string.exit_setup, (dialog, which) -> {
                dialog.dismiss();
                finish();
            })
            .show();
}
 
Example 13
Source Project: styT   Source File: ws_Main3Activity.java    License: Apache License 2.0 6 votes vote down vote up
private void eoou2(String dec) {
    //com.tencent.mm.plugin.scanner.ui.BaseScanUI
    final SharedPreferences i = this.getSharedPreferences("Hero", 0);
    Boolean o0 = i.getBoolean("FIRST", true);
    if (o0) {//第一次
        AppCompatDialog alertDialog = new AlertDialog.Builder(ws_Main3Activity.this)
                .setTitle("快捷功能")
                .setMessage("需要ROOT才能使用")
                .setNeutralButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        i.edit().putBoolean("FIRST", false).apply();
                    }
                }).setCancelable(false).create();
        alertDialog.show();
    } else {
        ShellUtils.execCommand("am start -n com.eg.android.AlipayGphone/" + dec, true, true);
    }
}
 
Example 14
Source Project: YImagePicker   Source File: WeChatPresenter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 拍照点击事件拦截
 *
 * @param activity  当前activity
 * @param takePhoto 拍照接口
 * @return 是否拦截
 */
@Override
public boolean interceptCameraClick(@Nullable final Activity activity, final ICameraExecutor takePhoto) {
    if (activity == null || activity.isDestroyed()) {
        return false;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setSingleChoiceItems(new String[]{"拍照", "录像"}, -1, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            if (which == 0) {
                takePhoto.takePhoto();
            } else {
                takePhoto.takeVideo();
            }
        }
    });
    builder.show();
    return true;
}
 
Example 15
Source Project: iroha-android   Source File: RegistrationActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void didRegistrationError(Throwable error) {
    dismissProgressDialog();
    AlertDialog alertDialog = new AlertDialog.Builder(this)
            .setTitle(getString(R.string.error_dialog_title))
            .setMessage(error.getCause() instanceof ConnectException ?
                    getString(R.string.general_error) :
                    error.getLocalizedMessage())
            .setCancelable(true)
            .setPositiveButton(android.R.string.ok, (dialog, which) -> {
                if (error.getCause() instanceof ConnectException) {
                    finish();
                }
            })
            .create();
    alertDialog.show();
}
 
Example 16
Source Project: Gojuon   Source File: ResultDialogHelper.java    License: MIT License 6 votes vote down vote up
private void init() {
    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    LayoutInflater inflater = LayoutInflater.from(mContext);
    View view = inflater.inflate(R.layout.fragment_result, null);

    builder.setCancelable(false)
            .setView(view)
            .setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    if (mRunnable != null) mRunnable.run();
                }
            });

    mResultDialog = builder.create();
}
 
Example 17
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View rootView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_portrait_seletor_layout, null);

    RecyclerView recyclerView = rootView.findViewById(R.id.recyclerview);
    recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 5));
    PortraitAdapter adapter = new PortraitAdapter();
    recyclerView.setAdapter(adapter);
    int padding = ViewUtils.dp2Px(getContext(), 2);
    recyclerView.addItemDecoration(new SpaceItemDecoration(padding, padding, padding, padding));

    return new AlertDialog.Builder(getContext())
            .setTitle(R.string.pick_portrait)
            .setNegativeButton(R.string.text_cancel, null)
            .setView(rootView)
            .create();
}
 
Example 18
Source Project: LocationAware   Source File: LocationAlarmActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override public void showAddCheckPointDialog() {
  LatLng target = mMap.getCameraPosition().target;
  AlertDialog.Builder builder = new AlertDialog.Builder(context);
  View dialogView =
      LayoutInflater.from(context).inflate(R.layout.set_checkpoint_dialog_view, null, false);
  ((TextView) dialogView.findViewById(R.id.check_point_lat_tv)).setText(
      String.valueOf(target.latitude));
  ((TextView) dialogView.findViewById(R.id.check_point_long_tv)).setText(
      String.valueOf(target.longitude));
  EditText nameEditText = dialogView.findViewById(R.id.check_point_name_et);
  AlertDialog alertDialog = builder.setView(dialogView).show();
  RxView.clicks(dialogView.findViewById(R.id.set_checkpoint_done_btn)).subscribe(__ -> {
    String enteredText = nameEditText.getText().toString();
    if (enteredText.length() >= 4) {
      locationPresenter.onSetCheckPoint(enteredText, target.latitude, target.longitude);
      alertDialog.dismiss();
    } else {
      nameEditText.setError("Name should have minimum of 4 characters.");
    }
  });
  RxView.clicks(dialogView.findViewById(R.id.set_checkpoint_cancel_btn))
      .subscribe(__ -> alertDialog.dismiss());
}
 
Example 19
Source Project: recurrence   Source File: RepeatSelector.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override @NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final String[] repeatArray = getResources().getStringArray(R.array.repeat_array);
    AlertDialog.Builder builder = new AlertDialog.Builder(getContext(), R.style.Dialog);
    builder.setItems(repeatArray, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            if (which == Reminder.SPECIFIC_DAYS) {
                DialogFragment daysOfWeekDialog = new DaysOfWeekSelector();
                daysOfWeekDialog.show(getActivity().getSupportFragmentManager(), "DaysOfWeekSelector");
            }  else if (which == Reminder.ADVANCED) {
                DialogFragment advancedDialog = new AdvancedRepeatSelector();
                advancedDialog.show(getActivity().getSupportFragmentManager(), "AdvancedSelector");
            } else {
                listener.onRepeatSelection(RepeatSelector.this, which, repeatArray[which]);
            }
        }
    });
    return builder.create();
}
 
Example 20
Source Project: delion   Source File: OMADownloadHandler.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Shows a warning dialog indicating that download has failed. When user confirms
 * the warning, a message will be sent to the notification server to  inform about the
 * error.
 *
 * @param titleId The resource identifier for the title.
 * @param omaInfo Information about the OMA content.
 * @param downloadInfo Information about the download.
 * @param statusMessage Message to be sent to the notification server.
 */
private void showDownloadWarningDialog(
        int titleId, final OMAInfo omaInfo, final DownloadInfo downloadInfo,
        final String statusMessage) {
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                sendInstallNotificationAndNextStep(omaInfo, downloadInfo,
                        DownloadItem.INVALID_DOWNLOAD_ID, statusMessage);
            }
        }
    };
    new AlertDialog.Builder(
            ApplicationStatus.getLastTrackedFocusedActivity(), R.style.AlertDialogTheme)
            .setTitle(titleId)
            .setPositiveButton(R.string.ok, clickListener)
            .setCancelable(false)
            .show();
}
 
Example 21
Source Project: AppPlus   Source File: DialogUtil.java    License: MIT License 6 votes vote down vote up
public static AlertDialog getProgressDialog(Activity context,String title, String message){
    View view = LayoutInflater.from(context).inflate(R.layout.dialog_progress, null);
    ProgressBar progressBar = (ProgressBar) view.findViewById(android.R.id.progress);
    TextView textView = (TextView) view.findViewById(R.id.content);

    //改变Progress的背景为MaterialDesigner规范的样式
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        progressBar.setIndeterminateDrawable(new CircularProgressDrawable(Utils.getColorWarp(context, R.color.colorAccent), context.getResources().getDimension(R.dimen.loading_border_width)));
    }

    final AlertDialog progressDialog = new AlertDialog.Builder(context)
            .setTitle(title)
            .setView(view).create();
    //设置显示文字
    textView.setText(message);

    return progressDialog;
}
 
Example 22
Source Project: material-calendarview   Source File: CustomTileDimensions.java    License: MIT License 6 votes vote down vote up
@OnClick(R.id.custom_tile_width_size)
public void onWidthClick() {
  final NumberPicker view = new NumberPicker(this);
  view.setMinValue(24);
  view.setMaxValue(64);
  view.setWrapSelectorWheel(false);
  view.setValue(currentTileWidth);
  new AlertDialog.Builder(this)
      .setView(view)
      .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(@NonNull DialogInterface dialog, int which) {
          currentTileWidth = view.getValue();
          widget.setTileWidthDp(currentTileWidth);
        }
      })
      .show();
}
 
Example 23
Source Project: MemoryCleaner   Source File: SettingFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override public void showThemeChooseDialog() {
    AlertDialog.Builder builder = DialogUtils.makeDialogBuilder(activity);
    builder.setTitle(R.string.change_theme);
    Integer[] res = new Integer[] { R.drawable.deep_purple_round,
            R.drawable.brown_round, R.drawable.blue_round,
            R.drawable.blue_grey_round, R.drawable.yellow_round,
            R.drawable.red_round, R.drawable.pink_round,
            R.drawable.green_round };
    List<Integer> list = Arrays.asList(res);
    ColorsListAdapter adapter = new ColorsListAdapter(getActivity(), list);
    adapter.setCheckItem(
            ThemeUtils.getCurrentTheme(activity).getIntValue());
    GridView gridView = (GridView) LayoutInflater.from(activity)
                                                 .inflate(
                                                         R.layout.colors_panel_layout,
                                                         null);
    gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
    gridView.setCacheColorHint(0);
    gridView.setAdapter(adapter);
    builder.setView(gridView);
    final AlertDialog dialog = builder.show();
    gridView.setOnItemClickListener((parent, view, position, id) -> {
        dialog.dismiss();
        mSettingPresenter.onThemeChoose(position);
    });
}
 
Example 24
Source Project: YTPlayer   Source File: PurchaseActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void setSuccess(String uid, DatabaseReference ref) {
    ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage("Processing...");
    dialog.setCancelable(false);
    dialog.show();
    ref.child(uid).setValue("paypal").addOnSuccessListener(runnable -> {
        dialog.dismiss();
        doOnSuccess();
    }).addOnFailureListener(runnable -> {
        dialog.dismiss();
        new AlertDialog.Builder(this)
                .setTitle("Error")
                .setMessage("Payment has completed successfully, but the app could not process it. Click on LEARN MORE to solve this error!")
                .setCancelable(false)
                .setPositiveButton("Learn More",(dialogInterface, i) -> {
                    helpClick(null);
                })
                .setNegativeButton("Cancel",null)
                .show();
    });
}
 
Example 25
Source Project: CameraMaskDemo   Source File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void showNewVersionDialog(String content, final String fileName) {
    new AlertDialog.Builder(this)
            .setTitle("新版本提示")
            .setMessage(content)
            .setPositiveButton("更新", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String url = BuildConfig.BASE_URL + BuildConfig.DOWNLOAD_URL;
                    Uri uri = Uri.parse(String.format(Locale.CHINA, url, fileName));
                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                    startActivity(intent);

                }
            })
            .setNegativeButton("知道了", null)
            .show();
}
 
Example 26
Source Project: xifan   Source File: WirteStatusActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void showChooseDialog() {
    new AlertDialog.Builder(this).setItems(getResources().getStringArray(R.array.photo_choose),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    switch (i) {
                        case 0:
                            openCamera();
                            break;
                        case 1:
                            pickPhoto();
                            break;
                    }
                }
            }).show();
}
 
Example 27
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
            .setTitle(R.string.dialog_startup_title)
            .setNegativeButton(R.string.dialog_startup_negative_button, null)
            .setPositiveButton(R.string.dialog_startup_positive_button, onPositiveButtonClickListener);
    // Get the layout inflater
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View viewRoot = inflater.inflate(R.layout.dialog_startup, null);
    HtmlTextView htmlTextView = (HtmlTextView) viewRoot.findViewById(R.id.html_text);

    String htmlContent =
            "<p>"+getString(R.string.html_text_purpose)+"</p>"+
            "<p>"+getString(R.string.html_text_free)+"</p>"+
            "<p>"+getString(R.string.html_text_donation)+"</p>";

    htmlTextView.setHtml(htmlContent);
    builder.setView(viewRoot);

    return builder.create();
}
 
Example 28
Source Project: accountBook   Source File: SpendingActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Add an income and expense record
 * @param v
 */
public void OnAddRecordClick(View v){
    final String[] items = {"收入", "支出"};
    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
    alertBuilder.setTitle("请选择添加类别");
    alertBuilder.setItems(items, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            //Toast.makeText(SpendingActivity.this, items[i], Toast.LENGTH_SHORT).show();
            Intent intent=new Intent(SpendingActivity.this,ExpenseProcesActivity.class);
            intent.putExtra("strType", i);
            SpendingActivity.this.startActivity(intent);
            alertDialog_AddRecord.dismiss();
        }
    });
    alertDialog_AddRecord = alertBuilder.create();
    alertDialog_AddRecord.show();
}
 
Example 29
Source Project: fingen   Source File: ActivityImportSms.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handleMessage(Message msg) {
    switch (msg.what) {
        case HANDLER_OPERATION_SHOW:
            progressbarArr[0].setVisibility(View.VISIBLE);
            break;
        case HANDLER_OPERATION_UPDATE:
            progressbarArr[0].setProgress(msg.arg1);
            break;
        case HANDLER_OPERATION_HIDE:
            break;
        case HANDLER_OPERATION_COMPLETE:
            if (activityArr[0].isFinishing()) return;
            AlertDialog.Builder builder = new AlertDialog.Builder(activityArr[0]);
            builder.setTitle(R.string.ttl_import_complete);

            builder.setMessage((String) msg.obj);

            // Set up the buttons
            builder.setPositiveButton("OK", onDialogOkListenerArr[0]);

            builder.show();
            break;
    }
}
 
Example 30
Source Project: TimetableView   Source File: LocalConfigActivity.java    License: MIT License 5 votes vote down vote up
/**
 * 从文本导入本地配置
 */
private void loadLocalConfigSet() {
    if(configSet==null){
        AlertDialog.Builder builder=new AlertDialog.Builder(this)
                .setTitle("配置导入")
                .setMessage("还没有导出,先导出再来试试吧")
                .setPositiveButton("我知道了",null);
        builder.create().show();
    }else{
        mScheduleConfig.load(configSet);
        Toast.makeText(this,"配置已生效",Toast.LENGTH_SHORT).show();
    }
    mTimetableView.updateView();
}