How can i add title to this custom dialog??
I have tried like this
Why not use an AlertDialog
if you have 3 or less buttons?
My AlertDialog looks like this:
My java code:
LayoutInflater inflater = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.add_filter, null);
AlertDialog alertDialog = new AlertDialog.Builder(this)
.create();
alertDialog.setTitle("AlertDialog title");
alertDialog.setMessage("AlertDialog message");
alertDialog.setView(view);
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
});
alertDialog.show();
My XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<Spinner
android:id="@+id/spinner_filter"
android:layout_width="wrap_content"
android:spinnerMode="dropdown"
android:layout_height="wrap_content"
android:entries="@array/filter_array"
android:prompt="@string/filter_prompt" />
</LinearLayout>
Simple yet does what you need.