java错误消息传递二进制XML文件行#0:错误膨胀类
以前它很好,没有错误,但我不知道什么时候我再次运行它,它变成了错误。这是一个碎片活动。当我打开它的时候,它离主要活动很近。我已经尝试创建一个新的xml并重命名它,但它根本不起作用
这是我的个人资料片段。java
public class ProfilFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private OnFragmentInteractionListener mListener;
public ProfilFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment ProfilFragment.
*/
// TODO: Rename and change types and number of parameters
public static ProfilFragment newInstance(String param1, String param2) {
ProfilFragment fragment = new ProfilFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_profile, container, false);
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.安卓.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
这是我的个人资料。xml
<安卓.support.design.widget.CoordinatorLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:app="http://schemas.安卓.com/apk/res-auto"
xmlns:card_view="http://schemas.安卓.com/apk/res-auto"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:fitsSystemWindows="true"
tools:context=".MainActivity">
<安卓.support.design.widget.AppBarLayout
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:theme="@style/AppTheme.AppBarOverlay">
<安卓.support.v7.widget.Toolbar
安卓:id="@+id/tool_bar"
安卓:layout_width="match_parent"
安卓:layout_height="?attr/actionBarSize"
安卓:background="@color/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" >
<TextView
安卓:textColor="@安卓:color/white"
安卓:text="Profile"
安卓:layout_marginLeft="11dp"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:textStyle="bold"
安卓:textSize="20dp"/>
</安卓.support.v7.widget.Toolbar>
</安卓.support.design.widget.AppBarLayout>
<FrameLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:background="#d2cfcf">
<!-- TODO: Update blank fragment layout -->
<安卓.support.v4.widget.NestedScrollView
安卓:layout_width="match_parent"
安卓:layout_height="match_parent">
<LinearLayout
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:orientation="vertical">
<View
安卓:layout_width="match_parent"
安卓:layout_height="?attr/actionBarSize" />
<LinearLayout
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:orientation="vertical">
<LinearLayout
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:orientation="vertical">
<ImageView
安卓:layout_width="match_parent"
安卓:layout_height="130dp"
安卓:layout_gravity="center_horizontal"
安卓:layout_margin="10dp"
安卓:src="@drawable/man" />
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_gravity="center_horizontal"
安卓:text="Joko Tingkir"
安卓:textColor="@安卓:color/black"
安卓:textSize="25dp" />
</LinearLayout>
<安卓.support.v7.widget.CardView
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_marginLeft="10dp"
安卓:layout_marginRight="10dp"
安卓:layout_marginTop="10dp"
card_view:cardCornerRadius="2dp">
<LinearLayout
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:background="@drawable/rectangle"
安卓:orientation="vertical">
<LinearLayout
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:orientation="horizontal">
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginLeft="10dp"
安卓:text="UangKu: "
安卓:textColor="@color/colorPrimary"
安卓:textSize="25dp" />
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:text="Rp. 70.000,-"
安卓:textColor="@安卓:color/black"
安卓:textSize="25dp" />
</LinearLayout>
<LinearLayout
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:orientation="horizontal">
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginLeft="10dp"
安卓:text="No Rekening: "
安卓:textColor="@安卓:color/black"
安卓:textSize="16dp" />
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:text="34-5563-4564-34"
安卓:textColor="@安卓:color/black"
安卓:textSize="15dp" />
</LinearLayout>
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginLeft="10dp"
安卓:text="A/N: NarutoU"
安卓:textColor="@安卓:color/black" />
</LinearLayout>
</安卓.support.v7.widget.CardView>
</LinearLayout>
<安卓.support.v7.widget.CardView
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_marginLeft="10dp"
安卓:layout_marginRight="10dp"
安卓:layout_marginTop="10dp"
card_view:cardCornerRadius="2dp">
<LinearLayout
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:background="@drawable/rectangle"
安卓:orientation="vertical"
安卓:padding="10dp">
<TextView
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:text="Profil Diri"
安卓:textColor="@color/colorPrimary"
安卓:textSize="20dp" />
<View
安卓:layout_width="match_parent"
安卓:layout_height="1dp"
安卓:layout_marginTop="5dp"
安卓:background="@安卓:color/darker_gray"></View>
<LinearLayout
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginTop="5dp"
安卓:orientation="horizontal">
<ImageView
安卓:layout_width="20dp"
安卓:layout_height="20dp"
安卓:src="@drawable/mailijo" />
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginLeft="10dp"
安卓:text="uzumaki.naruto@konoha.com"
安卓:textColor="@安卓:color/black" />
</LinearLayout>
<LinearLayout
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginTop="5dp"
安卓:orientation="horizontal">
<ImageView
安卓:layout_width="20dp"
安卓:layout_height="20dp"
安卓:src="@drawable/sex_type" />
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginLeft="10dp"
安卓:text="Pria"
安卓:textColor="@安卓:color/black" />
</LinearLayout>
<LinearLayout
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginTop="5dp"
安卓:orientation="horizontal">
<ImageView
安卓:layout_width="20dp"
安卓:layout_height="20dp"
安卓:src="@drawable/handphone" />
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginLeft="10dp"
安卓:text="081290188409"
安卓:textColor="@安卓:color/black" />
</LinearLayout>
<LinearLayout
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginTop="5dp"
安卓:orientation="horizontal">
<ImageView
安卓:layout_width="20dp"
安卓:layout_height="20dp"
安卓:src="@drawable/rumah" />
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginLeft="10dp"
安卓:text="Konoha, Kab. Konohagakure, Negara Api, Indonesia"
安卓:textColor="@安卓:color/black" />
</LinearLayout>
<LinearLayout
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginTop="5dp"
安卓:orientation="horizontal">
<ImageView
安卓:layout_width="20dp"
安卓:layout_height="20dp"
安卓:src="@drawable/kalender" />
<TextView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginLeft="10dp"
安卓:text="10 Oktober 1997"
安卓:textColor="@安卓:color/black" />
</LinearLayout>
</LinearLayout>
</安卓.support.v7.widget.CardView>
<View
安卓:layout_width="match_parent"
安卓:layout_height="50dp"
安卓:layout_marginTop="5dp"></View>
</LinearLayout>
</安卓.support.v4.widget.NestedScrollView>
</FrameLayout>
我突然发现了这个错误消息
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mqa.安卓.ewasapp, PID: 16111
安卓.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class <unknown>
Caused by: 安卓.view.InflateException: Binary XML file line #0: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at 安卓.view.LayoutInflater.createView(LayoutInflater.java:652)
at com.安卓.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at 安卓.view.LayoutInflater.onCreateView(LayoutInflater.java:742)
at 安卓.view.LayoutInflater.createViewFromTag(LayoutInflater.java:810)
at 安卓.view.LayoutInflater.createViewFromTag(LayoutInflater.java:752)
at 安卓.view.LayoutInflater.rInflate(LayoutInflater.java:883)
at 安卓.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at 安卓.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at 安卓.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at 安卓.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at 安卓.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at 安卓.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at 安卓.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at 安卓.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at 安卓.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at 安卓.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at 安卓.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at 安卓.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at 安卓.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at 安卓.view.LayoutInflater.inflate(LayoutInflater.java:522)
at 安卓.view.LayoutInflater.inflate(LayoutInflater.java:430)
at com.mqa.安卓.ewasapp.ProfilFragment.onCreateView(ProfilFragment.java:67)
at 安卓.support.v4.app.Fragment.performCreateView(Fragment.java:2354)
at 安卓.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419)
at 安卓.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
at 安卓.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809)
at 安卓.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799)
at 安卓.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
at 安卓.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
at 安卓.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
at 安卓.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229)
at 安卓.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700)
at 安卓.os.Handler.handleCallback(Handler.java:754)
at 安卓.os.Handler.dispatchMessage(Handler.java:95)
at 安卓.os.Looper.loop(Looper.java:163)
at 安卓.app.ActivityThread.main(ActivityThread.java:6337)
at java.lang.reflect.Method.invoke(Native Method)
at com.安卓.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.安卓.internal.os.ZygoteInit.main(ZygoteInit.java:770)
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 34776012 byte allocation with 16777216 free bytes and 32MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at 安卓.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at 安卓.graphics.BitmapFactory.decodeStream(BitmapFactory.java:624)
at 安卓.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:457)
at 安卓.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1152)
at 安卓.content.res.ResourcesImpl.createFromResourceStream(ResourcesImpl.java:1272)
at 安卓.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:743)
E/AndroidRuntime: at 安卓.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:585)
at 安卓.content.res.MiuiResourcesImpl.loadDrawable(MiuiResourcesImpl.java:308)
at 安卓.content.res.Resources.loadDrawable(Resources.java:872)
at 安卓.content.res.TypedArray.getDrawable(TypedArray.java:930)
at 安卓.widget.ImageView.<init>(ImageView.java:157)
at 安卓.widget.ImageView.<init>(ImageView.java:145)
at 安卓.widget.ImageView.<init>(ImageView.java:141)
这是我的身材。格拉德尔
apply plugin: 'com.安卓.application'
安卓 {
compileSdkVersion 26
defaultConfig {
applicationId "com.mqa.安卓.ewasapp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "安卓.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-安卓.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.安卓.support:appcompat-v7:26.1.0'
implementation 'com.安卓.support:design:26.1.0'
implementation 'com.安卓.support.constraint:constraint-layout:1.0.2'
implementation 'com.安卓.support:support-vector-drawable:26.1.0'
implementation 'com.安卓.support:support-v4:26.1.0'
implementation 'com.google.安卓.gms:play-services-plus:11.8.0'
testImplementation 'junit:junit:4.12'
安卓TestImplementation 'com.安卓.support.test:runner:1.0.1'
安卓TestImplementation 'com.安卓.support.test.espresso:espresso-core:3.0.1'
compile 'com.google.安卓.gms:play-services-maps:11.8.0'
compile 'com.安卓.support:design:26.1.0'
compile 'com.安卓.support:cardview-v7:26.1.0'
compile 'com.google.安卓.gms:play-services-location:11.8.0'
}
消息人士说这一行的错误
return inflater.inflate(R.layout.fragment_profile, container, false);
请帮我修一下
# 1 楼答案
在^{中添加两行:
复制并粘贴整个xml它将起作用:-
看这个:-
当我将你的代码复制到我的工作室时,这个错误将显示你可以在下面看到:-