Utilize o componente ListView para implementar a lista de alunos no layout. Para isso, remova os TextViews, adicione o componente ListView e no código Java busque-o com o findViewById().
Configure o Adapter a partir da classe ArrayAdapter enviando o contexto, layout do Android Framework (android.R.layout.simple_list_item_1) e a lista de alunos via argumento.
Execute o App e veja se aparece a lista como o esperado.
Implemente o FloatingActionButton como botão para adicionar novos alunos. Para isso, vá na paleta de View, filtre por FloatingActionButton e clique no botão que representa o download da dependência.
Assim que finalizar o processo do Gradle, adicione o FAB (FloatingActionButton) no layout. Em seguida converta o LinearLayout para RelativeLayout utilizando o menu Convert View... clicando com o botão direito em cima do LinearLayout a partir da aba Component Tree.
Por fim, mova o FAB para a parte inferior à direita da tela e execute o App. Confira se o layout é apresentado conforme o esperado.
Durante a aula vimos que o componente FloatingActionButton faz parte do Material Design que sugere algumas regras de implementação, como por exemplo, uma quantidade de margem de 16dp para a parte inferior... Para mais detalhes sobre a especificação, confira a página destinada à implementação do FloatingActionButton. (Ambas as referências são em Inglês)
Aprendemos que o Android framework nos disponibiliza algumas medidas para definir tamanhos fixos de seus elementos, como é o caso de pixel (px) e o pixel independente da densidade (dp). Além dessas opções também temos outras.
Dentre as demais medidas, uma que é importante ter conhecimento é a pixel independente da escala (sp) que tem um comportamento similar ao dp, porém, é destinada ao conteúdo via texto, como é o caso do tamanho de texto de um TextView.
Além dela, temos outras possibilidades que podem ser conferidas diretamente na documentação do Android Developers na seção mais recursos no tópico de dimensões. (em Inglês)
No geral, utilizamos o dp e o sp, portanto, você não precisa se preocupar tanto com as demais unidades.
https://developer.android.com/training/basics/firstapp/creating-project?hl=pt-br
https://www.tutorialspoint.com/android/android_architecture.htm
The Application Framework layer provides many higher-level services to applications in the form of Java classes. Application developers are allowed to make use of these services in their applications.
The Android framework includes the following key services −
Activity Manager − Controls all aspects of the application lifecycle and activity stack.
Content Providers − Allows applications to publish and share data with other applications.
Resource Manager − Provides access to non-code embedded resources such as strings, color settings and user interface layouts.
Notifications Manager − Allows applications to display alerts and notifications to the user.
View System − An extensible set of views used to create application user interfaces.
There are following four main components that can be used within an Android application −
(
Every activity you define for your application must be declared in your AndroidManifest.xml file and the main activity for your app must be declared in the manifest with an <intent-filter> that includes the MAIN action and LAUNCHER category
)
An activity represents a single screen with a user interface,in-short Activity performs actions on the screen. For example, an email application might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails. If an application has more than one activity, then one of them should be marked as the activity that is presented when the application is launched.
An activity is implemented as a subclass of Activity class as follows −
public class MainActivity extends Activity {}
A service is a component that runs in the background to perform long-running operations. For example, a service might play music in the background while the user is in a different application, or it might fetch data over the network without blocking user interaction with an activity.
A service is implemented as a subclass of Service class as follows −
public class MyService extends Service {}
Broadcast Receivers simply respond to broadcast messages from other applications or from the system. For example, applications can also initiate broadcasts to let other applications know that some data has been downloaded to the device and is available for them to use, so this is broadcast receiver who will intercept this communication and will initiate appropriate action.
A broadcast receiver is implemented as a subclass of BroadcastReceiver class and each message is broadcaster as an Intent object.
public class MyReceiver extends BroadcastReceiver { public void onReceive(context,intent){}}
A content provider component supplies data from one application to others on request. Such requests are handled by the methods of the ContentResolver class. The data may be stored in the file system, the database or somewhere else entirely.
A content provider is implemented as a subclass of ContentProvider class and must implement a standard set of APIs that enable other applications to perform transactions.
public class MyContentProvider extends ContentProvider { public void onCreate(){}}
We will go through these tags in detail while covering application components in individual chapters.
]
<uses-permission android:name="ACCESS_WIFI_STATE (Quando o usuario for baixar a google play avisa quais sao as permissoes que o app precisa)
<application
<activity
android:name=".MainActivity"
<intent-filter
<action android:name= MAIN
<category android:name="LAUNCHER
Arquivo inicial chamado
Arquivo R.java
ele junta todos os codigos Java com tudo que for adicionado nas pastas
app>build>generated>source>r>debug>app.primeiro.projeto> R
strings.xml
Arquivo com os textos da aplicação
dimens.xml
<dimen name = "horizontal_margin">16dp</dimen>
<dimen name = "horizontal_margin">16dp</dimen>
<dimen name = "horizontal_margin">25sp</dimen>
SP = scale independet pixel - para dimensionar as fontes