To display a Dialog with a custom content,
ViewGroup myRootViewGroup = /* root ViewGroup of your activity or fragment */; mContext = /* your activity context */; AlertDialog.Builder builder = new AlertDialog.Builder (mContext, AlertDialog.THEME_HOLO_DARK); LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.mylayout, (ViewGroup) myRootViewGroup); builder.setView(layout); Dialog dialog = builder.create(); dialog.show(); . . . dialog.dismiss();
great answer at Creating a custom dialog in Android on this also.
You might also consider that the layout your looking for is basically the standard AlertDialog layout (with no buttons), you can just do builder.setIcon() and builder.setTitle().
For your layout, change LinearLayout orientation="horizontal", remove the FrameLayout altogether, set ImageView layout_width="wrap_content". This:
<LinearLayout android:id="@id/mylayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src=""/> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@strings/text" /> </LinearLayout>
You'll also likely want to fiddle with padding on the Image/Text Views to get the exact look.