我如何实现插件在布局工作



我正在看这个插件,我想改变演示使用布局,而不是在代码中编写一切。

    // note that you can also define your own views directly in a resource XML, too by using:
    // <de.marcreichelt.android.RealViewSwitcher
    //     android:layout_width="fill_parent"
    //     android:layout_height="fill_parent"
    //     android:id="@+id/real_view_switcher">
    //         <!-- your views here -->
    // </de.marcreichelt.android.RealViewSwitcher>

所以这是可能的,但我不能让它工作。我做了两种布局。在主布局中有这个

<?xml version="1.0" encoding="utf-8"?>
<de.marcreichelt.android.RealViewSwitcher
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:id="@+id/real_view_switcher">
<include android:id="@+id/myid1" layout="@layout/second" />
 </de.marcreichelt.android.RealViewSwitcher>

我得到这个错误通过

Description Resource    Path    Location    Type
error: Error parsing XML: unbound prefix    main.xml    /RealViewSwitcher/res/layout    line 2  Android AAPT Problem

所以我想我需要给它一个命名空间或其他东西,但我不确定该使用什么。

我只是试了我唯一知道的一个

xmlns:android="http://schemas.android.com/apk/res/android

//第二布局。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/relativeLayout1" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        xmlns:android="http://schemas.android.com/apk/res/android">
    <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="1" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_marginLeft="82dp" android:layout_marginTop="57dp"></TextView>
</RelativeLayout>

在自定义标签中使用

xmlns:android="http://schemas.android.com/apk/res/android

最新更新