Я хочу использовать закусочный в моем приложении поэтому я ниже кода для этогоAndroid: закусочная не работает в классе фрагмента
public class FragmentAddProperty extends Fragment
{
RelativeLayout mRelative
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.layout_1,
container, false);
mRelative = (RelativeLayout) view.findViewById(R.id.edt_pro_city);
Snackbar.make(mRelative, "No images.", Snackbar.LENGTH_LONG).show();
}
}
EDIT
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/edt_pro_city"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f8f8f8"
android:orientation="vertical" >
<ImageView
android:id="@+id/sample_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/icon_list"
android:visibility="visible" />
</RelativeLayout>
В результате я получил следующее сообщение об ошибке
java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.support.design.widget.Snackbar$SnackbarLayout
Как я могу это решить?
Все внушение заметны
Snackbar.make (view, "No images.", Snackbar.LENGTH_LONG) .show(); – Tomislav
введите код xml. –
попробуйте 'build -> clean' в IDE и запустите его снова – Blackbelt