这是我的班级
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 */
}
我应该将什么作为参数传递给建造者?
答案 0 :(得分:4)
我认为你缺少alertdialog.show()
方法,它显示了控件
http://developer.android.com/reference/android/app/AlertDialog.Builder.html
答案 1 :(得分:2)
您必须在show()
上调用AlertDialog
方法。