My dialog has a list, and when this list has many entries, the dialog cuts the buttons in the middle, as in the image:
HowdoIsetamaximumheightfornotbeingcutlikethis?
DialogCode
publicvoiddeleteCategoria(intdespesa){mAba=despesa;finalCategoriaDAOdao=newCategoriaDAO(this);finalList<Categoria>list=dao.getLista(despesa);ArrayAdapter<Categoria>aa=newArrayAdapter<>(this,android.R.layout.select_dialog_multichoice,list);finalListViewlv=newListView(this);lv.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);lv.setAdapter(aa);AlertDialog.Builderab=newAlertDialog.Builder(this).setTitle("Apagar categorias");
ab.setView(lv);
ab.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
return;
}
});
ab.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int len = lv.getCount();
SparseBooleanArray checked = lv.getCheckedItemPositions();
for (int y = 0; y < len; y++) {
if (checked.get(y)) {
CategoriaDAO catDAO = new CategoriaDAO(getApplicationContext());
Categoria item = list.get(y);
catDAO.deletar(item);
}else if(checked.size() == 0){
Toast.makeText(getApplicationContext(), "Selecione uma categoria", Toast.LENGTH_SHORT).show();
break;
}
}
Intent intente = new Intent(getApplicationContext(), CategoriaListActivity.class);
intente.putExtra("aba", mAba);
intente.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK + Intent.FLAG_ACTIVITY_NO_ANIMATION);
getApplicationContext().startActivity(intente);
}
});
ab.show();
}