我試圖建立一個自定義alertdialog,其中有3 ImageViews
。我想隱藏和動態顯示這些ImageViews
。這裏是我的showroute()在HomeActivity類中,創建自定義對話框。更改alertdialog中的圖像瀏覽的可見性-Android
AlertDialog.Builder alertDialog = new AlertDialog.Builder(HomeActivity.this);
alertDialog.setView(getLayoutInflater().inflate(R.layout.routedialog, null));
alertDialog.setTitle("Home Activity");
alertDialog.setIcon(R.drawable.logo);
alertDialog.setMessage(Html.fromHtml("<b>Route Details</b>"));
ImageView iv1,iv2,iv3;
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View convertView = (LinearLayout) inflater.inflate(R.layout.routedialog, null);
iv1=(ImageView) convertView.findViewById(R.id.iv1);
iv2=(ImageView) convertView.findViewById(R.id.iv2);
iv3=(ImageView) convertView.findViewById(R.id.iv3);
iv1.setVisibility(View.GONE);
iv2.setVisibility(View.GONE);
iv3.setVisibility(View.GONE);
convertView.findViewById(R.id.ll).invalidate();
,這裏是我的routedialog.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp" >
<ImageView
android:id="@+id/iv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ivred" />
<ImageView
android:id="@+id/iv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ivblue" />
<ImageView
android:id="@+id/iv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ivgreen" />
</LinearLayout>
我想這些ImageViews
當對話管理器彈出,並具有一定的檢查幫助conditions.Please後動態地讓用戶看到它們被隱藏。
謝謝在檢查一些條件後顯示。 – Lal
@Lal將可見性設置爲'INVISIBLE'。或者在xml中爲視圖'andorid:visibility =「INVISIBLE」'。然後在條件使其可見 – Raghunandan
@Lal的快照是隻顯示你的對話框作品 – Raghunandan