开发者

How do I implement plugin to work in layouts?

I am looking at this plugin and I wwant to change the demo to use layouts instead of writing everything in code.

    // 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>

So it is possible to do it but I can't get it work. I made 2 layouts. In my main layout I have this

<?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>

I get this error though

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

So I think I need to give it a namespace or something but I am not sure what to use.

I just tried the only one I know

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

//second layout.

<?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:textAppearanc开发者_StackOverflow社区e="?android:attr/textAppearanceLarge" android:text="1" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_marginLeft="82dp" android:layout_marginTop="57dp"></TextView>

</RelativeLayout>


Use the

xmlns:android="http://schemas.android.com/apk/res/android
in the custom tag. It should work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜