小编Chr*_*ian的帖子

运行应用程序时android.view.Space的ClassNotFoundException

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

<?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>
Run Code Online (Sandbox Code Playgroud)

我得到的错误是这样的:

11-26 11:14:09.875:E/AndroidRuntime(10485):FATAL EXCEPTION:main
...
11-26 11:14:09.875:E/AndroidRuntime(10485):java.lang.RuntimeException:无法启动活动ComponentInfo {com.infoit.nfc.activity/com.infoit.nfc.activity.ViewTag}:android.view.InflateException:二进制XML文件行#23:错误膨胀类空间
...
11-26 11:14:09.875:E/AndroidRuntime(10485):引起:android.view.InflateException:二进制XML文件行#23:错误膨胀类空间
...
11-26 11:14:09.875:E/AndroidRuntime(10485):引起:java. lang.ClassNotFoundException:android.view.Space在loader dalvik.system.PathClassLoader [/data/app/com.infoit.nfc.activity-2.apk]中
......

如果我删除空间元素,一切都是桃子敏锐的.不知何故,即使我认为定义xmlns可以解决问题,它也无法找到Space类.我觉得这很简单,但我很想念它.

android android-layout classnotfoundexception

4
推荐指数
3
解决办法
2574
查看次数

以编程方式添加时自定义视图不膨胀布局

我正在尝试以编程方式将自定义视图添加到线性布局.我希望自定义视图膨胀我已经创建的布局.当我创建自定义视图的实例并添加它时,一个点显示视图的位置,但布局似乎没有膨胀(将我的自定义布局的背景颜色设置为绿色,但我看不到空间中的绿色,也不是布局中的图像).

我的自定义视图:

public class AddressView extends View {

  public AddressView(Context context) {
    super(context);
    View.inflate(context, R.layout.place_address, null);
  }

  public AddressView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    View.inflate(context, R.layout.place_address, null);
  }

  public AddressView(Context context, AttributeSet attrs) {
    super(context, attrs);
    View.inflate(context, R.layout.place_address, null);
  }
}
Run Code Online (Sandbox Code Playgroud)

我的自定义视图布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/address_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#00ff00" >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/house_1" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我在活动中的实例化:

LinearLayout content = (LinearLayout) findViewById(R.id.content);

AddressView addressView = new AddressView(this);
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, 400);
content.addView(addressView, …
Run Code Online (Sandbox Code Playgroud)

android

3
推荐指数
1
解决办法
6970
查看次数

iphone 4和iphone 5的相机覆盖高度

我正在使用标准的UIImagePickerController并使用相机覆盖视图,默认控件.我有一个外部nib文件,我加载了覆盖视图.问题是视图似乎是460,所以不完全包含iphone 5上的摄像头视图.我想使用自动布局来解决这个问题,但我不知道如何告诉笔尖调整它的尺寸可以是iphone 4或iphone 5的高度.

我想过使用setFrame,但这是非自动布局.我还想过有2个不同的nib文件,一个用于iphone 4,另一个用于iphone 5,但这似乎也是错误的方法.我猜有一些方法可以告诉笔尖填充当前的摄像头视图,但我不确定它是什么.有人可以推荐"正确"的方式来处理这个问题吗?

iphone ios

3
推荐指数
1
解决办法
2161
查看次数