Layout for Dialog - R.layout.view_with_plus
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.util.me.TestActivity"
>
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Details"/>
<fragment
android:layout_toRightOf="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/email"
class="com.util.me.test.PlusOneFragment"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
How to show the Dialog
public void showDialog(View vIew){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
View view = this.getLayoutInflater().inflate(R.layout.view_with_plus, null);
builder.setView(view)
.setPositiveButton("OK", null)
.setNegativeButton("Cancel", null);
AlertDialog dialog = builder.create();
dialog.show();
}
The fragment in class="com.util.me.test.PlusOneFragment" is just a PlusOneFragment generated by Android Studio.