2017-11-29 26 views
1

私が知る限り、@ + idと@idの違いは、最初にリソースIDを作成し、既に存在するリソースIDを別の場所に再利用することです。たとえば、2つのtextViewを1つずつ持つRelativeレイアウトがある場合、最初のTextViewを参照する2番目のtextViewには@resourceIdを使用します。 アンドロイドスタジオを3.0にアップデートした後、@ resourceIdがもう動作しません。最初のものの下に2番目のtextViewを配置するには、@ firstTextViewIdの代わりに@ + firstTextViewIdを使用する必要があります。具体的には、私はここでは、コード@idが内部で動作していません相対レイアウト

<RelativeLayout 
    android:id="@+id/relBottomLayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true"> 
    <TextView 
     android:id="@+id/totalQty" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="abcdef"/> 
    <TextView 
     android:id="@+id/totalPrice" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/totalQty" 
     android:text="saasdfdsdfsdf"/> 

    <TextView 
     android:id="@+id/totalNetPrice" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/totalPrice" 
     android:text="abcdsadfsafddgfdgfgdef" 
     /> 
</RelativeLayout> 

それは理解の問題ですが、

android:layout_below="@+id/totalQty" 

代わり

android:layout_below="@id/totalQty" 

の使用する必要がありますか?または任意の終わりからの問題?誰でも説明できますか?

+0

あなたのレイアウトのルートは何ですか? – Bek

+0

プロジェクトをクリーニングして再構築しようとしましたか? –

+1

新しいツールはファイルを別々に処理する可能性があります。必ずしもトップダウンである必要はありません。そのため、 '@ id 'の前に' @ id'を打っている可能性があります。どこでも '@ + id'を使うだけです。それは何も傷つけるつもりはない。 –

答えて

0
I just remove + sign at @+id from your code. Here's the updated code 

<RelativeLayout android:id="@+id/relBottomLayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 
    <TextView 
     android:id="@+id/totalQty" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="abcdef"/> 
    <TextView 
     android:id="@+id/totalPrice" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/totalQty" 
     android:text="saasdfdsdfsdf"/> 

    <TextView 
     android:id="@+id/totalNetPrice" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/totalPrice" 
     android:text="abcdsadfsafddgfdgfgdef" 
     /> 
</RelativeLayout> 
関連する問題