当我开始开发 android 应用程序时,我倾向于在任何需要的地方定义自定义 R 值,特别是在布局文件中。例如:
findViewById(R.id.customerName).setText(customer.getName())
与布局:
<TextView android:text="TextView" android:id="@id/customerName"
android:layout_height="wrap_content" android:layout_width="fill_parent" />
现在我意识到,使用它可能会更好android.R
。
findViewById(android.R.id.text1).setText(customer.getName())
与布局:
<TextView android:text="TextView" android:id="@android:id/text1"
android:layout_height="wrap_content" android:layout_width="fill_parent" />
你遵循什么惯例?各自的优点和缺点是什么?