-1
嗨在不明白爲什麼我得到這個錯誤,父視圖不是一個TextView任何幫助,將不勝感激。我嘗試了幾件事情,但似乎沒有任何工作。10-08 10:23:40.433:E/MoreInfoHPW_ViewGroup(10127):父視圖不是一個TextView
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.custom_toast_screen_pass, (ViewGroup)findViewById(R.id.layout_pass));
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_SHORT);
toast.setView(layout);
toast.show();
<ImageView
android:id="@+id/approval_icn"
android:layout_height="40dp"
android:layout_width="40dp"
android:src="@drawable/approval_icon"
android:layout_gravity="center_vertical" >
</ImageView>
<TextView
android:id="@+id/pass_txt"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:text="Congratulations you have passed the quiz" >
</TextView>
</LinearLayout>
的OP問同樣的問題在幾個小時前:http://stackoverflow.com/questions/26252328/10-08-102340- 433-E-moreinfohpw-viewgroup10127父 - 視圖 - 是 - 不-A-textvie – Nija 2014-10-08 12:46:39