AlertDialog.Builder setView - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AlertDialog.Builder setView method.

This code example shows how to use the following methods:setPadding, addView, setView
	  return new AlertDialog.Builder(context)
	   .setTitle(title)
	   .setCancelable(true)
	   .setIcon(android.R.drawable.ic_dialog_info)
	   .setPositiveButton(button, null)
	   .setView(LinkifyText(context, text))
	   .create();
	 } 
 
		public static ScrollView LinkifyText(Context context, String message) 
		{ 
		    ScrollView svMessage = new ScrollView(context); 
		    TextView tvMessage = new TextView(context);
		 
		    SpannableString spanText = new SpannableString(message);
		 
		    Linkify.addLinks(spanText, Linkify.ALL);
		    tvMessage.setText(spanText);
		    tvMessage.setMovementMethod(LinkMovementMethod.getInstance());
		     

7
CodeRank
This code example shows how to use the following methods:loadData, setLayoutParams, setView
		if (mDialog != null) {
			mDialog.dismiss();
			mDialog = null;
		} 
		AlertDialog.Builder b = new AlertDialog.Builder(c);
		WebView html = new WebView(c);
		html.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
		html.loadData(loadAssetFile(c, c.getString(filenameid)), "text/html", "UTF-8");
		mDialog = b.setIcon(null)
				.setView(html)
				.setPositiveButton("OK", this)
				.show();
	} 
	 
	private String loadAssetFile(Context c, String name) {
		try { 
			BufferedReader r = new BufferedReader(new InputStreamReader(c.getAssets().open(name)));
			StringBuilder sb = new StringBuilder();
			do { 
				String line = r.readLine();
7
CodeRank
This code example shows how to use the following methods:setIcon, setNegativeButton, setPositiveButton, setView
		view.setPadding(Math.round(mColorPicker.getDrawingOffset()), 0, Math.round(mColorPicker.getDrawingOffset()), 0);
 
		final int val = getValue();
		mColorPicker.setColor(val, true);
		mColorPicker.setAlphaSliderVisible(mAlphaSliderEnabled);
		builder.setView(view);
		builder.setIcon(new BitmapDrawable(context.getResources(), getColorPreviewBitmap(context, val)));
		builder.setPositiveButton(android.R.string.ok, this);
		builder.setNegativeButton(android.R.string.cancel, null);
	} 
 
	@Override 
	protected void onSetInitialValue(final boolean restoreValue, final Object defaultValue) {
		if (isPersistent() && defaultValue instanceof Integer) {
			persistInt(restoreValue ? getValue() : (Integer) defaultValue);
		} 
	} 
 
	private int getValue() { 
		try { 
8
CodeRank
This code example shows how to use the following methods:setLayoutParams, setNumStars, setOnRatingBarChangeListener, setRating, setStepSize
This code example shows how to use the following methods:setAdapter, setView
	private Context context;
 
    public RunnableDialog(Context context, String title) {
        this.context = context;
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, actions);
		list = new ListView(context);
		list.setAdapter(adapter);
		dialogBuilder = new AlertDialog.Builder(context).setTitle(title).setView(list);
	} 
	 
	public RunnableDialog Action(String text, Runnable runnable) {
		actions.add(text);
		commands.add(runnable);
		return this;
	} 
 
	public RunnableDialog Action(String text, Runnable runnable, boolean show) {
		if (!show) {
			return this;
		} 
6
CodeRank
This code example shows how to use the following methods:setText, addTextChangedListener, setView
import net.miginfocom.layout.IDEUtil; 
 
public class ComponentResizer { 
    public static void openResizer(final View view){
        final MigLayout.LayoutParams oldParams = (MigLayout.LayoutParams) view.getLayoutParams();
        final EditText input = new EditText(view.getContext());
        input.setText(oldParams.getConstraintString());
        final AlertDialog alert = new AlertDialog.Builder(view.getContext())
            .setTitle("Update Layout")
            .setView(input)
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {}
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                if (view.getLayoutParams() != oldParams) {
                    view.setLayoutParams(oldParams);
                } 
            } 
        }).show();
        input.addTextChangedListener(new TextWatcher() {

6
CodeRank
This code example shows how to use the following methods:setAdapter, setView
	private Context context;
 
	public RunnableDialog(Context context, String title) {
		this.context = context;
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, actions);
		list = new ListView(context);
		list.setAdapter(adapter);
		dialogBuilder = new AlertDialog.Builder(context).setTitle(title).setView(list);
	} 
	 
	public RunnableDialog Action(String text, Runnable runnable) {
		actions.add(text);
		commands.add(runnable);
		return this;
	} 
 
	public RunnableDialog Action(String text, Runnable runnable, boolean show) {
		if (!show) {
			return this;
		} 
6
CodeRank
This code example shows how to use the following methods:setInputType, setView
     * @param context 
     * @param theme 
     * @return 
     */ 
    public static Dialog makeNumericPromptDialog(final Context context, String prompt, final OnResultListener listener) {
    	final EditText etResult = new EditText(context);
    	etResult.setInputType(InputType.TYPE_CLASS_NUMBER);
    	AlertDialog.Builder builder = new AlertDialog.Builder(context);
    	builder.setMessage(prompt)
    	       .setCancelable(false)
    	       .setView(etResult)
    	       .setPositiveButton("OK", new DialogInterface.OnClickListener() {
    	           public void onClick(DialogInterface dialog, int id) {
    	                listener.onResult(etResult.getText().toString());
    	           } 
    	       }) 
    	       .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
    	           public void onClick(DialogInterface dialog, int id) {
    	                dialog.cancel();
    	           } 
6
CodeRank
This code example shows how to use the following methods:getSettings, loadDataWithBaseURL, setLayoutParams, setView
7
CodeRank
This code example shows how to use the following methods:setView
		seekBar.setOnSeekBarChangeListener(this);
		layout.addView(seekBar);
 
		updateText(); 
 
		builder.setView(layout);
	} 
 
	/** 
	 * Format seconds into a human-readable time description. 
	 * 
	 * @param value The time, in seconds. 
	 * @return A human-readable string, such as "1 hour, 21 minutes" 
	 */ 
	private String formatTime(int value)
	{ 
		Resources res = getContext().getResources();
		StringBuilder text = new StringBuilder();
		if (value >= 3600) {
			int hours = value / 3600;
6
CodeRank

Related AlertDialog.Builder setView Questions & Answers:

setView Method Overview
Set a custom view to be the contents of the Dialog.
See Code Examples for other Android AlertDialog.Builder Methods: