Hello World differs on Android Studio version

Asked

Viewed 57 times

0

I was watching a video class of a guy who was using Android Studio version 1.3. As much is generated, he was just taking away what was not necessary. I was doing this process, but I realized that the result in 1.5.1, which is the version of the ide I use looks different.

Código onde o nome do projeto aparece

What happens is that his example lacked the last two lines of code:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

His example, using version 1.3 without the two lines above worked as it is in the emulator, but in 1.5.1 without these lines the name of the project, which is Agenda is no longer displayed.

Could someone explain to me why we have this difference?

  • To Activity of it extended AppCompatActivity also?

  • Also.. They just changed these lines

  • These two lines define the layout of the ActionBar programmatically. If his is working without it, it might be some theme setting.

1 answer

1


In the latest versions of Android Studio it is no longer necessary to set Actionbar programmatically when the class inherits from Appcompatactivity. Already defined by default in the theme.

Browser other questions tagged

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