I have settings activity under my project. And i created two RadioGroups RadioGroup1 and RadioGroup2 under it. Radio button ids under both are named as Radio0, Radio1 and Radio2. If i change id of Radio0 to rb1 under RadioGroup1 it changes Radio0 to rb1 under RadioGroup2 too. Why is that? How can i add onclick events on those this way?

有帮助吗?

解决方案

Generally speaking, all views inside the same layout file should have different ids. A good practice would even be specifying different ids for all elements across all layout files.

Ids are used to uniquely specify each element in your layout. Two elements with the same ID is always a bad idea.

In eclipse, delete the whole "id" attribute, then rewrite it. When you start writing the content of the quotation marks, write the word "id", then hit ctrl+space, then enter. a "@+id/" text should appear, then you can type the new ID and other IDs shouldn't change

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top