Lets say that I have the a layout named activity_main.xml and it has an element:
<TextView
android:id="@+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
An activity named MainActivity.java. In its' onCreate method, I inflate the above layout using viewBinding, and set text of text view:
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
binding.textView.setText("some text");
}
Now, if I rename the id of TextView in activity_main.xml, by pressing Shift+F6
to something like @+id/text_view_new
, then the reference in onCreate
doesn't changed from binding.textView.setText("some text");
to binding.textViewNew.setText("some text");
Is this behaviour a limitation, a bug or am I doing something wrong?