Android custom dialog

This will create a custom dialog.

AlertDialog.Builder builder;
AlertDialog alertDialog;
 
Context mContext = this;
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.help_dialog, (ViewGroup) findViewById(R.id.layout_root));
 
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText(getString(R.string.help_string));
 
builder = new AlertDialog.Builder(mContext);
builder.setView(layout);
alertDialog = builder.create();
 
alertDialog.show();

And create a “help_dialog.xml” this name is from the inflater

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_root"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dp"
    >
    <TextView android:id="@+id/text"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:textColor="#FFF"
        />
</LinearLayout>

LayoutInflater at android dev