As you can see, below the bottom list item in my ListView there is excess space that I cannot get rid of. I tried Relative and Linearlayout, both look like this. Here is the code:
public class ChooseDialog extends DialogFragment implements DialogInterface.OnClickListener { String URLhome; String Title; String type; public ChooseDialog(String type) { this.type = type; } @Override public void onCreate(Bundle bundle) { super.onCreate(bundle); setCancelable(true); int style = DialogFragment.STYLE_NORMAL, theme = 0; setStyle(style, theme); } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(type); builder.setNegativeButton("Cancel", this); LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View dialogLayout = inflater.inflate(R.layout.dialog, null); builder.setView(dialogLayout); final String[] items = {"Red", "Green", "Blue" }; builder.setAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, items), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Log.v("touched: ", items[which].toString()); }} ); return builder.create(); } @Override public void onClick(DialogInterface dialog, int which) {
And the code that launches the dialog:
public OnClickListener listener = new OnClickListener() { public void onClick(View v) { showNationalityDialog(); } }; private void showNationalityDialog() { FragmentManager fm = getSupportFragmentManager(); ChooseDialog nationalityDialog = new ChooseDialog("Nationality"); nationalityDialog.show(fm, "fragment_edit_name"); }
source share