本文介绍了运行应用程序时android.view.Space的ClassNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当活动布局中存在某些元素时,我在运行应用程序时遇到问题.我具有以下布局,并且在包含"Space"元素时遇到了问题:

I'm having an issue running my application when certain elements exist in the layout of my activity. I have the following layout, and I have issue when I include the "Space" element:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="vertical" >

<Button
       android:id="@+id/button1"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_alignParentBottom="true"
       android:layout_alignParentLeft="true"
       android:text="@string/foursquare" />

<Button
      android:id="@+id/button2"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_above="@+id/foursquare_button"
      android:layout_alignParentLeft="true"
      android:text="@string/yelp" />

<Space
    android:layout_width="match_parent"
    android:layout_height="100px"
    android:layout_weight="0.18" />
</LinearLayout>

我得到的错误是:

如果我删除了Space元素,那么一切都会变得扑朔迷离.即使我以为定义xmlns可以解决问题,但还是无法找到Space类.我觉得这很简单,但是我很想念它.

If I remove the Space element everything is peachy keen. Somehow it's not able to find the Space class even though I thought defining the xmlns would solve the issue. I feel this is something simple, but I am missing it.

推荐答案

xml文件需要引用由平台或您自己的项目定义的现有小部件,而Space不是标准的Android小部件.尝试将其替换为View.

The xml file needs to refer to existing widgets either defined by the platform or by your own project, and Space is not a standard Android widget. Try replacing it with View instead.

这篇关于运行应用程序时android.view.Space的ClassNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 08:24