2017-11-29 1 views
1

알다시피, @ + id와 @id의 차이점은 리소스 ID를 처음 생성하고 이미 존재하는 리소스 ID를 다른 위치에 재사용하는 것입니다. 예를 들어, 두 개의 textView가 서로 아래에있는 Relative 레이아웃이있는 경우 첫 번째 TextView를 참조하는 두 번째 textView에 @resourceId를 사용합니다. android studio를 3.0으로 업데이트 한 후에 문제가 발생합니다. @resourceId가 더 이상 작동하지 않습니다. 두 번째 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> 
관련 문제