我正在尝试制作一个可滚动的选项卡,但当我在我的片段布局中设置一个视图时,应用程序开始出现错误,因为错误inflating类为空。它在未添加视图时工作,但当我在布局中添加视图时,它会给我错误。我也按此处给出的那样添加了类,但它不起作用。我如何在这里修复这个问题是我的片段代码
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.neelay.anotherbeatbox.Fragment.Songs"
android:background="@color/colorPrimaryDark"
class = "com.example.neelay.anotherbeatbox.Fragment.Songs">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
<view
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#fff"
android:layout_marginTop="150dp"/>
</FrameLayout>
片段包名称为包com。实例尼莱。另一个盒子。碎片片段名称歌曲。我怎样才能解决这个问题?错误
E/AndroidRuntime: FATAL EXCEPTION: main
android.view.InflateException: Binary XML file line #14: Error inflating class null
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at com.example.neelay.anotherbeatbox.Fragment.Songs.onCreateView(Songs.java:27)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2074)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:758)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1632)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:637)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
at com.antonyt.infiniteviewpager.InfinitePagerAdapter.finishUpdate(InfinitePagerAdapter.java:67)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1237)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1085)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1611)
at android.view.View.measure(View.java:15356)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:622)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:404)
at android.view.View.measure(View.java:15356)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4928)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:671)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:738)
at android.view.View.measure(View.java:15356)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4928)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:315)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
at android.view.View.measure(View.java:15356)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4928)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1457)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:723)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:583)
at android.view.View.measure(View.java:15356)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4928)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:315)
at android.view.View.measure(View.java:15356)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4928)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1457)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:723)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:583)
at android.view.View.measure(View.java:15356)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4928)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:315)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2148)
at android.view.View.measure(View.java:15356)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1858)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1110)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1283)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1008)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4222)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92
D/dalvikvm:GC_并发释放343K,10%释放6423K/7111K,暂停12ms 16ms,总计53ms
我的片段类
package com.example.neelay.anotherbeatbox.Fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.neelay.anotherbeatbox.R;
public class Songs extends Fragment {
public Songs() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_songs, container, false);
}
}
您需要为视图类定义正确的包名称。通过查看类中定义的包名称,您可以在布局xml中像这样定义它
<com.example.neelay.anotherbeatbox.Fragment.Songs
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#fff"
android:layout_marginTop="150dp"/>
替换
<view
具有
<View
View
是一个实际的小部件,您可以对其进行膨胀,并且似乎适合您的预期目的。view
是一个特殊的标签,使用它您可以通过在属性中定义的名称来膨胀视图类,并且您还没有定义这样的类名(它在膨胀器中显示为null
)。
我想创建应用程序,其中NavigationView和底部导航相互工作,但在输出中,我在“Run”中得到了下一个字符串 . 菜单 请帮帮我,我不知道如何修复这个错误)
我得到了一个错误,这是我的XML文件 这里是styles.xml 我尝试将AppCompat更改为MaterialComponents,但它不起作用。但是当我指向LinearLayout标记(com.google.android.Material.TextField.TextInputLayout的父标记)时,它会用红线显示错误,当我移除LinearLayout标记时,它会消失。当我使用太多的Li
我试图实现方法底部导航视图,但当我运行代码时,我得到了这个错误 build.gradle(模块应用程序)
我想创建一个应用程序,其中NavigationView和Bottom Navigation可以互相工作,但在输出中,我在“Run”中得到了下一个字符串。 .
当我尝试构建我的android应用程序时,我如何修复这个问题。我将实现'com.google.android.gms:play-services-ads:19.8.0'更新为实现'com.google.android.gms:play-services-ads:20.4.0',现在我得到了这个错误。 jetified-play-services-measurement-18.0.2-runtime
ProjectAAA.obj:错误LNK2001:未解析的外部符号" public:_ this call X::class event::class event(unsigned int)"(??0类事件@X@@QAE@I@Z) 我已经定义了不知道如何修复这个LINK错误。 欢迎提出任何建议。 谢谢你 更多信息: 1. 现在我已经完全隔离了错误: 1.