Я создаю диалог, и мой фрагмент XML находится в диалоге.Строка двоичного XML-файла # 25: Ошибка надувания фрагмента класса: В dialof XML,.at layout.HomeFragment $ 1.onClick (HomeFragment.java:39): Просмотреть layoutView = inflater.inflate (R.layout.guide_dialog, container);
Возможно, мне следует создать класс Java для фрагмента!
btn_Guide.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final AlertDialog.Builder builder = new
AlertDialog.Builder(getContext());
View layoutView = inflater.inflate(R.layout.guide_dialog, container);
builder.setView(layoutView);
final Button btnOk = (Button) layoutView.findViewById(R.id.btnOk);
final AlertDialog alertdialog = builder.create();
alertdialog.getWindow().setBackgroundDrawable(new
ColorDrawable(Color.TRANSPARENT));
alertdialog.show();
btnOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
alertdialog.dismiss();
}
});
/ Диалог XML:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="20dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_guide"
android:gravity="center"
android:orientation="vertical"
android:padding="50dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8"
android:orientation="horizontal">
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment"
android:name="layout.GuideInDialog"
android:layout_width="match_parent"
android:layout_height="250dp"
tools:layout="@layout/fragment_guide_in_dialog"
/>
</LinearLayout>
/ Фрагмент XML
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="layout.GuideInDialog">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="7dp">
<TextView
android:id="@+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="It`s my fragment"
android:textColor="#ffffff"
android:textSize="23sp"/>
</LinearLayout>
</ScrollView>
</FrameLayout>