Olá! Eu estou com o código idêntico ao da aula, porém só o primeiro aluno é mostrado na lista! (estou usando o Android Studio 2.3 e usando meu próprio celular para executar a aplicação)
Segue o código da classe e do xml:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lista_alunos);
String [] alunos= {"Daniel","Ronaldo", "Jeferson", "Felipe"} ;
ListView listaAlunos = (ListView) findViewById(R.id.lista_de_alunos);
ArrayAdapter<String> adapter = new ArrayAdapter <String> (this, android.R.layout.simple_list_item_1, alunos);
listaAlunos.setAdapter(adapter);
}
Eu também tentei inserir no vetor pelo método normal:
String[] alunos = new String[3];
alunos[0] = "Hudson";
alunos[1] = "Daniel";
alunos[2] = "Bla";
Porém, não funciona da mesma maneira.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
>
<LinearLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/lista_de_alunos"
/>
</LinearLayout>
</ScrollView>
Alguém pode me ajudar?