диалоговое окно предупреждения внутри setClickOnListener не отображается - PullRequest
0 голосов
/ 09 октября 2011

Это мой класс

    public class TeamUpAttack extends OrmLiteBaseActivity<DatabaseHelper> {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.teamup_attack);
 /* more code */
            Button toComplete = (Button) findViewById(R.id.attack_confirm);
            toComplete.setOnClickListener(toCompleteH);
 /* more code */
        }

/* more code */

        View.OnClickListener toCompleteH = new View.OnClickListener() {
            public void onClick(View v) {
                try {
                    List<Player> pl = getHelper().getPlayerDao().query( getHelper().getPlayerDao().queryBuilder().where().not().eq("Posizione", "NA").prepare() );
                    Log.e("TEAMUPATTACCK", v.getClass().getCanonicalName());
                    if(pl.size()==11) v.getContext().startActivity(new Intent(v.getContext(), GeneratedFormation.class));
                    else {
                        AlertDialog.Builder alert_bld;

                        alert_bld = new AlertDialog.Builder(TeamUpAttack.this);
                        alert_bld.setNegativeButton("OK", new DialogInterface.OnClickListener(){
                            public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                            }
                        });
                        AlertDialog alert = alert_bld.create();
                        alert.setMessage("You must choose 11 players");
                        alert.setIcon(R.drawable.icon);

                    }
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        };

 /* more code */

    }

Что я должен передать строителю в качестве аргумента?

Ответы [ 2 ]

4 голосов
/ 09 октября 2011

я думаю, что вам не хватает alertdialog.show() метод, который отображает элемент управления

http://developer.android.com/reference/android/app/AlertDialog.Builder.html

2 голосов
/ 09 октября 2011

Вы должны вызвать метод show() для AlertDialog.

...