Differences xml lines Android (Eclipse)

Asked

Viewed 124 times

2

Guys, in the course I do Android he works on the platform Eclipse(Old version) and I in the latest version, when the teacher uses the command: android.id in it’s all right, but if I type this line there is an error, I have to use the android:id for the command to work, someone can explain to me?

And when he type for ex: android:id="@+calcular/botao1 error in my line, but not in his, but if I type android:id="@+id/botao1 Yes I can compile.

Somebody help me by doing me a favor Thank you!

  • What error shows @Daniloalbergardi

  • As soon as I get home I made the mistake

  • android:id="@+id/linhameta" example taken from a layout of mine, can explain what this is android:id="@+calcular/botao1 calular?

  • if I write calculate(or any other word) instead of error id

  • I could understand, thank you for your attention!

  • What is the version of the Android API he is using and what is his?

Show 1 more comment

3 answers

2


Android-Studio is upgraded to the best performance of Android apps.

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

For in the old days as in Eclipse, let himself be used @+calcular/botao1, but it was seen that this could bring problems because Android now wants to treat @+id as a whole and if it were string @+calcular could in the future give problems in the application.

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

@+id/calcular_botao1

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

I hope I’ve helped.

  • I could understand, thank you for your attention!

  • Regarding android.id or android:id the old eclipse still did not treat this error, only when it was tested the application it appeared!

  • Only one thing wasn’t the eclipse I let on @+calcular/botao1 was even the Android API. However it is as Alysson says, use prefix.

  • Nothing to do with Eclipse... It’s the Android API (sdk) problem.

0

In fact one should use:

android:id="@+id/id_do_componente"

I’ve never really studied the ancient eclipse, but I know the code was used this way.

  • I get it, but isn’t it all going to get messy inside the "id"? because in his code when he will call in java everything is grouped, eg: everything that involves the calculate button is in the group calculate android:id="@+calculate/id_do_component" ai the id_do_component are the subgroups that are created

  • It might even get disorganized, a little hard work won’t help, but it’ll work

  • I could understand, thank you for your attention!

0

To assign id's in its components use the form below:

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

In his Activity would look something like this:

 private TextView               textTituloGrupo;    

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

By your comment you could have a method calcularbotao(); to organize your code.

In this link you can look at other conventions

  • I could understand, thank you for your attention!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.