As far as I know, the difference between @+id and @id is to create a resource id first time and reuse that already existed resource id in different places. For instance, If we have a Relative layout having two textViews one below another, we shall use @resourceId for the second textView which refers to the first TextView. The problem is, after updating the android studio to 3.0, @resourceId is not working anymore.To place second textView below the first one, I need to use @+firstTextViewId instead of @firstTextViewId. More specifically I need to use,
android:layout_below="@+id/totalQty"
instead of
android:layout_below="@id/totalQty"
Here is the code
<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>
Is it an understanding issue? or a problem from any end? Can anyone please explain?
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>
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.