Example usage for android.app AlertDialog.Builder setIcon

List of usage examples for android.app AlertDialog.Builder setIcon

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setIcon.

Prototype

public void setIcon(Drawable icon) 

Source Link

Usage

From source file:br.liveo.ndrawer.ui.fragment.MainFragment32.java

private void successDialog() {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
    alertDialog.setTitle(" ? ");
    alertDialog.setMessage("? ? ??");
    alertDialog.setIcon(R.drawable.ic_dialog_alert);

    alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();/*w  ww . j  a  va  2  s  .com*/

            Fragment mFragment;
            FragmentManager mFragmentManager = getActivity().getSupportFragmentManager();

            mFragment = new ViewPagerFragment3();

            if (mFragment != null) {
                mFragmentManager.beginTransaction().replace(R.id.container, mFragment).commit();
            }
        }
    });

    alertDialog.show();
}

From source file:tcc.iesgo.activity.ClientMapActivity.java

@Override
public void onProviderDisabled(String arg0) {
    final AlertDialog.Builder dialog = new AlertDialog.Builder(getParent());
    dialog.setTitle(getString(R.string.gps_disabled));
    dialog.setMessage(getString(R.string.gps_disabled_message));
    dialog.setIcon(R.drawable.gps_enable);
    dialog.setCancelable(false);/*from   w w  w. j  a v  a  2s  . c o m*/

    dialog.setPositiveButton(getString(R.string.ad_button_positive), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            startActivity(intent);
        }
    });

    dialog.setNegativeButton(getString(R.string.ad_button_negative), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
            finish();
        }
    });
    dialog.show();
}

From source file:org.totschnig.myexpenses.dialog.ExportDialogFragment.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override/*w  ww . j a va 2  s . c o m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity ctx = (Activity) getActivity();
    Context wrappedCtx = DialogUtils.wrapContext1(ctx);
    Bundle args = getArguments();
    Long accountId = args != null ? args.getLong("accountId") : null;
    boolean allP = false;
    String warningText;
    if (accountId == null) {
        allP = true;
        warningText = getString(R.string.warning_reset_account_all);
    } else if (accountId < 0L) {
        allP = true;
        AggregateAccount aa = AggregateAccount.getCachedInstance(accountId);
        if (aa == null)
            throw new DataObjectNotFoundException(accountId);
        warningText = getString(R.string.warning_reset_account_all, " (" + aa.currency.getCurrencyCode() + ")");
    } else {
        warningText = getString(R.string.warning_reset_account);
    }
    LayoutInflater li = LayoutInflater.from(wrappedCtx);
    View view = li.inflate(R.layout.export_dialog, null);
    dateFormatET = (EditText) view.findViewById(R.id.date_format);
    String dateFormatDefault = ((SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT)).toPattern();
    String dateFormat = MyApplication.getInstance().getSettings().getString(PREFKEY_EXPORT_DATE_FORMAT, "");
    if (dateFormat.equals(""))
        dateFormat = dateFormatDefault;
    else {
        try {
            new SimpleDateFormat(dateFormat, Locale.US);
        } catch (IllegalArgumentException e) {
            dateFormat = dateFormatDefault;
        }
    }
    dateFormatET.setText(dateFormat);
    dateFormatET.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
            try {
                new SimpleDateFormat(s.toString(), Locale.US);
                mDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
            } catch (IllegalArgumentException e) {
                dateFormatET.setError(getString(R.string.date_format_illegal));
                mDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
            }
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });
    notYetExportedCB = (CheckBox) view.findViewById(R.id.export_not_yet_exported);
    deleteCB = (CheckBox) view.findViewById(R.id.export_delete);
    warningTV = (TextView) view.findViewById(R.id.warning_reset);
    formatRB = (RadioButton) view.findViewById(R.id.csv);
    String format = MyApplication.getInstance().getSettings().getString(MyApplication.PREFKEY_EXPORT_FORMAT,
            "QIF");
    boolean deleteP = true;
    if (format.equals("CSV"))
        (formatRB).setChecked(true);
    deleteCB.setOnClickListener(this);
    if (Account.getHasExported(accountId)) {
        deleteP = false;
        deleteCB.setChecked(false);
        notYetExportedCB.setChecked(true);
        notYetExportedCB.setVisibility(View.VISIBLE);
    }
    warningTV.setText(warningText);
    if (deleteP)
        warningTV.setVisibility(View.VISIBLE);
    else
        warningTV.setVisibility(View.GONE);
    AlertDialog.Builder builder = new AlertDialog.Builder(wrappedCtx)
            .setTitle(allP ? R.string.menu_reset_all : R.string.menu_reset).setView(view)
            .setPositiveButton(android.R.string.ok, this).setNegativeButton(android.R.string.cancel, null);
    if (Build.VERSION.SDK_INT < 11)
        builder.setIcon(android.R.drawable.ic_dialog_alert);
    else
        builder.setIconAttribute(android.R.attr.alertDialogIcon);
    mDialog = builder.create();
    return mDialog;
}

From source file:br.com.GUI.perfil.HomePersonal.java

public boolean onOptionsItemSelected(MenuItem item) {
    // Take appropriate action for each action item click
    switch (item.getItemId()) {

    case R.id.actSolicitacoesDeAmizadePersonal:
        ArrayList<Aluno> solicitacoes = new Aluno().buscarAlunoNaoConfirmadoPorPersonalWeb("",
                pref.getString("usuario", null));
        if (!solicitacoes.isEmpty()) {
            Intent i = new Intent(this, SolicitacoesDeAmizade.class);
            startActivity(i);// w w  w.  j a v a 2  s .  c  o m
        } else {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
            alertDialog.setTitle("Ops...");
            alertDialog.setMessage(R.string.label_voce_nao_possui_solicitacoes_de_amizade);
            alertDialog.setIcon(R.drawable.profile);
            alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
            // Showing Alert Message
            alertDialog.show();
        }

        return true;
    case R.id.actLogoutPersonal:
        finish();
        Intent login = new Intent(this, Login.class);
        login.putExtra("logout", true);
        editor.clear();
        editor.commit();
        startActivity(login);
        return true;
    case R.id.actAdicionarAlunos:
        Intent adicionarAlunos = new Intent(this, BuscarUsuario.class);
        startActivity(adicionarAlunos);
        return true;
    case R.id.actAlterarDadosPessoaisPersonal:
        if (pref.getBoolean("isFacebookUser", false)) {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(HomePersonal.this);
            alertDialog.setTitle("Erro");
            alertDialog.setMessage(
                    "Seu cadastro est vinculado ao Facebook, sendo assim, no  possivel alterao de informaes pessoais");
            alertDialog.setIcon(R.drawable.profile);
            alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
            // Showing Alert Message
            alertDialog.show();
        } else {
            Intent alterarDados = new Intent(this, AlterarDadosPessoais.class);
            startActivity(alterarDados);
        }

        return true;
    case R.id.actPerfil:
        Intent perfilIntent = new Intent(this, PerfilPersonal.class);
        startActivity(perfilIntent);
        return true;

    case R.id.actNovaAvaliacao:
        Intent avaliacoesIntent = new Intent(this, AvaliarGorduraCorporal.class);
        startActivity(avaliacoesIntent);
        return true;
    case R.id.actNovoTreinamento:

        AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
        alertDialog.setTitle("Ops...");
        alertDialog.setMessage("Digite um nome para o novo treinamento");
        alertDialog.setIcon(R.drawable.critical);

        // Set an EditText view to get user input 
        final EditText input = new EditText(this);
        alertDialog.setView(input);

        alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {

                Treinamento t = new Treinamento(0, input.getText().toString(), null, null,
                        pref.getString("usuario", null), null);

                //Log.i("interface: treinamento", t.toString());
                try {
                    int resultado = t.salvarTreinamentoWeb(b);
                    if (resultado > 0) {
                        Log.i("interface: salvei web", "salvei web");
                        t.setCodTreinamento(resultado);
                        if (t.salvarTreinamento(b, pref.getString("usuario", null))) {
                            Log.i("interface: salvei local", "salvei local");
                            Toast.makeText(HomePersonal.this, "Salvo com sucesso!", Toast.LENGTH_SHORT).show();
                        }
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                    Toast.makeText(HomePersonal.this, "Erro ao salvar!", Toast.LENGTH_SHORT).show();
                }
            }
        });
        alertDialog.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {

                dialog.dismiss();

            }
        });
        // Showing Alert Message
        alertDialog.show();

    }

    return false;
}

From source file:net.evecom.android.log.DailyLogAddActivity.java

/**
 * fh/*from  www. ja  v  a  2  s  .  com*/
 * 
 * @param v
 */
public void logfh(View v) {

    final AlertDialog.Builder builder = new AlertDialog.Builder(DailyLogAddActivity.this);
    builder.setTitle("");
    builder.setIcon(R.drawable.qq_dialog_default_icon);// 
    builder.setMessage("");
    builder.setPositiveButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            DailyLogAddActivity.this.finish();
            Intent intent = new Intent(getApplicationContext(), DailyLogListActivity.class);
            startActivity(intent);

        }
    });
    builder.setNegativeButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.show();

}

From source file:jp.co.rakuten.rakutenvideoplayer.base.BaseActivity.java

/**
 * Show dialog error//from ww  w  . j a v  a2 s.  c  o  m
 * @param errStr
 */
public void showDialogError(String errStr) {
    AlertDialog.Builder adb = new AlertDialog.Builder(this);
    adb.setIcon(R.drawable.icon);
    adb.setTitle(R.string.str_ErrPlay_Title);
    adb.setMessage(errStr);
    adb.setPositiveButton(R.string.str_OK, new OnClickListener() {
        public void onClick(DialogInterface a0, int a1) {
            finish();
        }
    });
    adb.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {

            if (keyCode == KeyEvent.KEYCODE_BACK) {
                dialog.dismiss();
                finish();

                return true;
            }

            return false;
        }

    });

    AlertDialog ad = adb.create();
    ad.show();
}

From source file:com.example.bhumiputra.FarmerHomeActivity.java

private void selectItem(int position) {
    // update the main content by replacing fragments

    Fragment fragment;/*from   w w w.  j  a va 2 s.c  o m*/
    Bundle bundle;

    FragmentManager fragmentManager;
    switch (position) {

    case 0:

        fragment = new FarmerFragmet();
        bundle = new Bundle();
        // bundle.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);
        fragment.setArguments(bundle);

        fragmentManager = getFragmentManager();
        fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

        // update selected item and title, then close the drawer
        mDrawerList.setItemChecked(position, true);
        setTitle(mFarmerTitles[position]);
        mDrawerLayout.closeDrawer(mDrawerList);

        break;
    case 1:

        fragment = new FarmerBuyFragmet();
        bundle = new Bundle();
        // bundle.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);
        fragment.setArguments(bundle);

        fragmentManager = getFragmentManager();
        fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

        // update selected item and title, then close the drawer
        mDrawerList.setItemChecked(position, true);
        setTitle(mFarmerTitles[position]);
        mDrawerLayout.closeDrawer(mDrawerList);

        break;

    case 2:

        fragment = new FarmerHireFragmet();
        bundle = new Bundle();
        // bundle.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);
        fragment.setArguments(bundle);

        fragmentManager = getFragmentManager();
        fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

        // update selected item and title, then close the drawer
        mDrawerList.setItemChecked(position, true);
        setTitle(mFarmerTitles[position]);
        mDrawerLayout.closeDrawer(mDrawerList);

        break;

    case 3:

        fragment = new FarmerSaleFragmet();
        bundle = new Bundle();
        // bundle.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);
        fragment.setArguments(bundle);

        fragmentManager = getFragmentManager();
        fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

        // update selected item and title, then close the drawer
        mDrawerList.setItemChecked(position, true);
        setTitle(mFarmerTitles[position]);
        mDrawerLayout.closeDrawer(mDrawerList);

        break;

    case 4:

        AlertDialog.Builder bulder = new AlertDialog.Builder(FarmerHomeActivity.this);
        bulder.setTitle("Are you sure ?....");
        bulder.setIcon(R.drawable.ic_launcher);
        bulder.setMessage("You want to Logout");
        bulder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                Intent intent = new Intent(FarmerHomeActivity.this, MainActivity.class);
                startActivity(intent);

            }
        });
        bulder.setNegativeButton("No", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                Toast.makeText(FarmerHomeActivity.this, "Welldone", Toast.LENGTH_LONG).show();
                dialog.dismiss();
            }
        });

        AlertDialog d = bulder.create();
        d.show();
        break;

    default:
        break;
    }

    /*   
            
            
     fragment = new FarmerFragmet();
       bundle = new Bundle();
      // bundle.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);
       fragment.setArguments(bundle);
            
      fragmentManager = getFragmentManager();
       fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
            
       // update selected item and title, then close the drawer
       mDrawerList.setItemChecked(position, true);
       setTitle(mFarmerTitles[position]);
       mDrawerLayout.closeDrawer(mDrawerList);
             
    break;
            
            
    case 5:   */

}

From source file:org.catrobat.paintroid.dialog.InfoDialog.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override/*w ww.  j  a  v a 2 s .c  om*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        builder = new AlertDialog.Builder(getActivity());
    } else {
        builder = new AlertDialog.Builder(getActivity(), AlertDialog.THEME_HOLO_DARK);
    }

    if (mTitleResource != NULL_RESOURCE) {
        builder.setTitle(mTitleResource);
    }

    int imageResource = mDialogType.getImageResource();
    if (imageResource != NULL_RESOURCE) {
        builder.setIcon(imageResource);
    }

    if (mMessageResource != NULL_RESOURCE) {
        builder.setMessage(mMessageResource);
    }

    builder.setNeutralButton(android.R.string.ok, this);
    return builder.create();
}

From source file:com.speed.traquer.app.Feedback_rate_taxi.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK)) {
        if (actv_comp_taxi.length() != 0 || inputTaxi.length() != 0) {
            final AlertDialog.Builder alertBox = new AlertDialog.Builder(Feedback_rate_taxi.this);
            alertBox.setIcon(R.drawable.info_icon);
            alertBox.setCancelable(false);
            alertBox.setTitle("Do you want to cancel feedback?");
            alertBox.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface arg0, int arg1) {
                    // finish used for destroyed activity
                    easyTracker.send(MapBuilder.createEvent("Feedback taxi", "Cancel Feedback taxi (Yes)",
                            "Feedback taxi event", null).build());
                    finish();/*  www  .j  av  a2  s .  c  o m*/
                    Intent intent = new Intent(Feedback_rate_taxi.this, Speedometer.class);
                    Feedback_rate_taxi.this.startActivity(intent);
                }
            });

            alertBox.setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int arg1) {
                    easyTracker.send(MapBuilder.createEvent("Feedback taxi", "Cancel Feedback taxi (No)",
                            "Feedback taxi event", null).build());
                    dialog.cancel();
                }
            });

            alertBox.show();
        } else {
            NavUtils.navigateUpFromSameTask(this);
            return true;
        }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:info.guardianproject.notepadbot.NoteCipher.java

private void handleDelete() {
    if (mCacheWord.isLocked()) {
        return;/*from   w  w  w .  j a  v  a 2 s .co  m*/
    }
    final AlertDialog.Builder b = new AlertDialog.Builder(this);
    b.setIcon(android.R.drawable.ic_dialog_alert);
    b.setTitle(R.string.app_name);
    b.setMessage(R.string.confirm_delete);
    b.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {

            // User clicked OK so go ahead and delete
            ContentResolver cr = getContentResolver();

            if (cr != null)
                cr.delete(dataStream, null, null);
            else {
                Toast.makeText(NoteCipher.this, R.string.unable_to_delete_original, Toast.LENGTH_SHORT).show();
            }

        }
    });
    b.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {

        }
    });
    b.show();
}