簡體   English   中英

layout_toRightOf:不允許的字符串類型

[英]layout_toRightOf: String types not allowed

我有以下控件:一行內有ListView和兩個TextView。

我正在嘗試使“ rowTextView”位於左側,而“ rowTextCount”位於其右側。

這是我的行的xml:

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

錯誤:不允許使用字符串類型(位於“ layout_toRightOf”,值為“ rowTextView”)

謝謝!

它是期望和id 更改為:

  android:layout_toRightOf="@id/rowTextView"

在這里您可以找到文檔

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM