如果您以前解决过此问题,请有人帮助我.
我正在尝试进行一些材料设计,以使应用程序可以运行至API10.我的代码没有任何错误,但我一直收到此错误.
Android LogCat
06-01 05:05:37.414: E/AndroIDRuntime(7043): FATAL EXCEPTION: main06-01 05:05:37.414: E/AndroIDRuntime(7043): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.chano8.app/com.chano8.app.MainActivity}: androID.vIEw.InflateException: Binary XML file line #19: Error inflating class androID.support.v7.internal.Widget.NativeActionModeAwareLayout06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2351)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2403)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.app.ActivityThread.access0(ActivityThread.java:165)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.os.Handler.dispatchMessage(Handler.java:107)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.os.Looper.loop(Looper.java:194)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.app.ActivityThread.main(ActivityThread.java:5370)06-01 05:05:37.414: E/AndroIDRuntime(7043): at java.lang.reflect.Method.invokeNative(Native Method)06-01 05:05:37.414: E/AndroIDRuntime(7043): at java.lang.reflect.Method.invoke(Method.java:525)06-01 05:05:37.414: E/AndroIDRuntime(7043): at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)06-01 05:05:37.414: E/AndroIDRuntime(7043): at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:600)06-01 05:05:37.414: E/AndroIDRuntime(7043): at dalvik.system.NativeStart.main(Native Method)06-01 05:05:37.414: E/AndroIDRuntime(7043): Caused by: androID.vIEw.InflateException: Binary XML file line #19: Error inflating class androID.support.v7.internal.Widget.NativeActionModeAwareLayout06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.vIEw.LayoutInflater.createVIEwFromTag(LayoutInflater.java:698)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.vIEw.LayoutInflater.rInflate(LayoutInflater.java:746)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.vIEw.LayoutInflater.parseInclude(LayoutInflater.java:805)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.vIEw.LayoutInflater.rInflate(LayoutInflater.java:736)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:489)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:396)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:352)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:324)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.support.v7.app.AppCompatDelegateImplV7.setContentVIEw(AppCompatDelegateImplV7.java:246)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.support.v7.app.AppCompatActivity.setContentVIEw(AppCompatActivity.java:106)06-01 05:05:37.414: E/AndroIDRuntime(7043): at com.chano8.app.MainActivity.onCreate(MainActivity.java:33)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.app.Activity.performCreate(Activity.java:5228)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1150)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2315)06-01 05:05:37.414: E/AndroIDRuntime(7043): ... 11 more06-01 05:05:37.414: E/AndroIDRuntime(7043): Caused by: java.lang.classNotFoundException: DIDn't find class "androID.support.v7.internal.Widget.NativeActionModeAwareLayout" on path: DexPathList[[zip file "/data/app/com.chano8.app-1.apk"],nativelibraryDirectorIEs=[/data/app-lib/com.chano8.app-1, /vendor/lib, /system/lib]]06-01 05:05:37.414: E/AndroIDRuntime(7043): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)06-01 05:05:37.414: E/AndroIDRuntime(7043): at java.lang.classLoader.loadClass(ClassLoader.java:501)06-01 05:05:37.414: E/AndroIDRuntime(7043): at java.lang.classLoader.loadClass(ClassLoader.java:461)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.vIEw.LayoutInflater.createVIEw(LayoutInflater.java:552)06-01 05:05:37.414: E/AndroIDRuntime(7043): at androID.vIEw.LayoutInflater.createVIEwFromTag(LayoutInflater.java:687)06-01 05:05:37.414: E/AndroIDRuntime(7043): ... 24 more
@H_419_11@以下是根据上述Logcat崩溃的我的代码.
MainActivity.javaprivate static String TAG = MainActivity.class.getSimplename();private Toolbar mToolbar;private FragmentDrawer drawerFragment;@OverrIDeprotected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); mToolbar = (Toolbar) findVIEwByID(R.ID.toolbar); setSupportActionbar(mToolbar); getSupportActionbar().setdisplayShowHomeEnabled(true); drawerFragment = (FragmentDrawer) getSupportFragmentManager().findFragmentByID(R.ID.fragment_navigation_drawer); drawerFragment.setUp(R.ID.fragment_navigation_drawer, (DrawerLayout) findVIEwByID(R.ID.drawer_layout), mToolbar); drawerFragment.setDrawerListener(this); // display the first navigation drawer vIEw on app launch displayVIEw(0);}
@H_419_11@FragmentDrawer.java
这是绘制我所需菜单的类.
private static String TAG = FragmentDrawer.class.getSimplename();private RecyclerVIEw recyclerVIEw;private ActionbarDrawerToggle mDrawerToggle;private DrawerLayout mDrawerLayout;private NavigationDrawerAdapter adapter;private VIEw containerVIEw;private static String[] Titles = null;private FragmentDrawerListener drawerListener;public FragmentDrawer() {}public voID setDrawerListener(FragmentDrawerListener Listener) { this.drawerListener = Listener;}public static List<NavDrawerItem> getData() { List<NavDrawerItem> data = new ArrayList<>(); // preparing navigation drawer items for (int i = 0; i < Titles.length; i++) { NavDrawerItem navItem = new NavDrawerItem(); navItem.setTitle(Titles[i]); data.add(navItem); } return data;}@OverrIDepublic voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // drawer labels Titles = getActivity().getResources().getStringArray(R.array.nav_drawer_labels);}@OverrIDepublic VIEw onCreateVIEw(LayoutInflater inflater, VIEwGroup container, Bundle savedInstanceState) { // Inflating vIEw layout VIEw layout = inflater.inflate(R.layout.fragment_navigation_drawer, container, false); recyclerVIEw = (RecyclerVIEw) layout.findVIEwByID(R.ID.drawerList); adapter = new NavigationDrawerAdapter(getActivity(), getData()); recyclerVIEw.setAdapter(adapter); recyclerVIEw.setLayoutManager(new linearlayoutmanager(getActivity())); recyclerVIEw.addOnItemtouchListener(new RecyclertouchListener(getActivity(), recyclerVIEw, new ClickListener() { @OverrIDe public voID onClick(VIEw vIEw, int position) { drawerListener.onDrawerItemSelected(vIEw, position); mDrawerLayout.closeDrawer(containerVIEw); } @OverrIDe public voID onLongClick(VIEw vIEw, int position) { } })); return layout;}@Suppresslint("NewAPI")public voID setUp(int fragmentID, DrawerLayout drawerLayout, final Toolbar toolbar) { containerVIEw = getActivity().findVIEwByID(fragmentID); mDrawerLayout = drawerLayout; mDrawerToggle = new ActionbarDrawerToggle(getActivity(), drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) { @OverrIDe public voID onDrawerOpened(VIEw drawerVIEw) { super.onDrawerOpened(drawerVIEw); getActivity().invalIDateOptionsMenu(); } @OverrIDe public voID onDrawerClosed(VIEw drawerVIEw) { super.onDrawerClosed(drawerVIEw); getActivity().invalIDateOptionsMenu(); } @OverrIDe public voID onDrawerSlIDe(VIEw drawerVIEw, float slIDeOffset) { super.onDrawerSlIDe(drawerVIEw, slIDeOffset); toolbar.set@R_404_5997@(1 - slIDeOffset / 2); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerLayout.post(new Runnable() { @OverrIDe public voID run() { mDrawerToggle.syncState(); } });}public static interface ClickListener { public voID onClick(VIEw vIEw, int position); public voID onLongClick(VIEw vIEw, int position);}static class RecyclertouchListener implements RecyclerVIEw.OnItemtouchListener { private GestureDetector gestureDetector; private ClickListener clickListener; @Suppresslint("NewAPI") public RecyclertouchListener(Context context, final RecyclerVIEw recyclerVIEw, final ClickListener clickListener) { this.clickListener = clickListener; gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { @OverrIDe public boolean onSingleTapUp(MotionEvent e) { return true; } @OverrIDe public voID onLongPress(MotionEvent e) { VIEw child = recyclerVIEw.findChildVIEwUnder(e.getX(), e.getY()); if (child != null && clickListener != null) { clickListener.onLongClick(child, recyclerVIEw.getChildposition(child)); } } }); } @OverrIDe public boolean onIntercepttouchEvent(RecyclerVIEw rv, MotionEvent e) { VIEw child = rv.findChildVIEwUnder(e.getX(), e.getY()); if (child != null && clickListener != null && gestureDetector.ontouchEvent(e)) { clickListener.onClick(child, rv.getChildposition(child)); } return false; } @OverrIDe public voID ontouchEvent(RecyclerVIEw rv, MotionEvent e) { } @OverrIDe public voID onRequestdisallowIntercepttouchEvent(boolean arg0) { // Todo auto-generated method stub }}public interface FragmentDrawerListener { public voID onDrawerItemSelected(VIEw vIEw, int position);}
@H_419_11@谢谢!
解决方法:
创建一个新项目,设置最低目标ID为10,将自动创建appcompat_v7库,然后在您的项目中将appcompat_v7添加为库.
我已经使用了导入V7库,那里有和你一样的错误,我解决了上面的方法.
总结以上是内存溢出为你收集整理的java-错误膨胀类android.support.v7.internal.widget.NativeActionModeAwareLayout全部内容,希望文章能够帮你解决java-错误膨胀类android.support.v7.internal.widget.NativeActionModeAwareLayout所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)