Android xml lines (Eclipse)

2

In the course I do Android, it works on the Eclipse platform (Old Version) and I in the latest version, when the teacher uses the command: android.id in it all, but if I type this line I have to use android:id for the command to work, can anyone explain me?

And when he types for eg: android:id="@+calcular/botao1 of error in my line, but not in it, but if I type android:id="@+id/botao1 yes I can compile.

Someone help me by favor, Thanks!

    
asked by anonymous 23.06.2015 / 20:08

3 answers

2

Android-Studio is updated for the best performance of Android applications.

According to Google Developer, in Android Studio you should leave @+id/ and then put the desired name of the component, example - @+id/botao1 .

Because in the old days as in Eclipse , you used @+calcular/botao1 , but you could see that this could cause problems because Android now wants to treat @+id as a whole and if it were string @+calcular could in the future give application problems.

The advice they give to make it more distinctive, is to use a prefix such as:

@+id/calcular_botao1

So @+id/ will be treated as a whole when Android compile the app avoiding errors that could happen if it were a string ( @+calcaular/ ).

I hope I have helped.

    
23.06.2015 / 22:08
0

To assign id's to your components use the form below:

<TextView   android:id="@+id/textTituloGrupo"/>

In your Activity it would look something like this:

 private TextView               textTituloGrupo;    

textTituloGrupo = (TextView) findViewById(R.id.textTituloGrupo);

For your review you could have a calcularbotao(); method to organize your code.

Here you can see other conventions

    
23.06.2015 / 21:28
0

You should actually use:

android:id="@+id/id_do_componente"

I never really studied the old Eclipse, but I know the code was used like this.

    
23.06.2015 / 20:37