简体   繁体   中英

layout_toRightOf: String types not allowed

I have the following controls: ListView and Two TextView's inside a row.

I'm trying to make the 'rowTextView' stand on the left and 'rowTextCount' right next to it on the right.

Here's my xml for the row:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000000"
    tools:context="com.k.l.MainActivity" >

<com.k.l.MyTextView xmlns:android="http://schemas.android.com/apk/res/android"  
     android:id="@+id/rowTextView"   
     android:layout_width="fill_parent"   
     android:layout_height="wrap_content"  
     android:padding="5dp"  
     android:textColor="#888"
     android:textSize="28sp" >  
</com.k.l.MyTextView>  

<com.k.l.MyTextView xmlns:android="http://schemas.android.com/apk/res/android"  
     android:id="@+id/rowTextCount"   
     android:layout_width="fill_parent"   
     android:layout_height="wrap_content"  
     android:padding="5dp"  
     android:textColor="#888"
     android:layout_toRightOf="rowTextView"
     android:text="666"
     android:textSize="28sp" >  
</com.k.l.MyTextView>  

</RelativeLayout>

Error: String types not allowed (at 'layout_toRightOf' with value 'rowTextView')

Thanks!

it is expecting and id . Change it to:

  android:layout_toRightOf="@id/rowTextView"

Here you can find the documentation

 <com.k.l.MyTextView xmlns:android="http://schemas.android.com/apk/res/android"  
     android:id="@+id/rowTextCount"   
     android:layout_width="fill_parent"   
     android:layout_height="wrap_content"  
     android:padding="5dp"  
     android:textColor="#888"
     android:layout_toRightOf="@+id/rowTextView"
     android:text="666"
     android:textSize="28sp" >  
</com.k.l.MyTextView>  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM