activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:id="@+id/activity_main_fab_novo_aluno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_margin="16dp"
android:clickable="true"
android:focusable="true" />
<ListView
android:id="@+id/activity_main_lista_de_alunos"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
MainActivity.java
package alura.com.agenda;
import android.app.Activity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView; import androidx.annotation.Nullable; import java.util.ArrayList; import java.util.Arrays; import java.util.List;
public class MainActivity extends Activity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
List<String> alunos = new ArrayList<>(
Arrays.asList("Alex", "Fran", "Jose", "Maria", "Ana"));
ListView listaDeAlunos = findViewById(R.id.activity_main_lista_de_alunos);
listaDeAlunos.setAdapter(new ArrayAdapter<>(
this,
android.R.layout.simple_list_item_1,
alunos));
}
}
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="Agenda"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>