Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

Tela emulada em branco

Meu JAVA:

package com.example.estagiario.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ListaAlunosActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lista_alunos);


        String[] Alunos = {"Jerry", "Paulo", "Daniela", "João"};
        ListView listaAlunos = (ListView) findViewById(R.id.lista_alunos);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
        listaAlunos.setAdapter(adapter);

meu XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

     <ListView
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:id="@+id/lista_alunos">
     </ListView>


</LinearLayout>

Log RUN:

02/01 10:07:27: Launching app
$ adb push /home/estagiario/AndroidStudioProjects/MyApplication2/app/build/outputs/apk/app-debug.apk /data/local/tmp/com.example.estagiario.myapplication
$ adb shell pm install -r "/data/local/tmp/com.example.estagiario.myapplication"
    pkg: /data/local/tmp/com.example.estagiario.myapplication
Success


$ adb shell am start -n "com.example.estagiario.myapplication/com.example.estagiario.myapplication.ListaAlunosActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 2382 on device emulator-5554
W/System: ClassLoader referenced unknown path: /data/app/com.example.estagiario.myapplication-1/lib/x86_64
I/InstantRun: Instant Run Runtime started. Android package is com.example.estagiario.myapplication, real application class is null.
W/System: ClassLoader referenced unknown path: /data/app/com.example.estagiario.myapplication-1/lib/x86_64
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
I/OpenGLRenderer: Initialized EGL, version 1.4
D/gralloc_ranchu: Emulator without host-side GPU emulation detected.

Event Log:

10:07:19 Gradle build finished in 21s 561ms
10:08:06 Instant Run re-installed and restarted the app
         (Dont show again)

Alguém pode me ajudar? Realmente não sei o porquê da tela branca!!

3 respostas
solução!

Você esqueceu de passar seu array de alunos pro ArrayAdapter.

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Alunos);

Uma observação:

Variáveis começam com letras minúsculas. Altere isso.

String [] alunos = {"Daniel","Ronaldo", "Jeferson", "Felipe"} ;
ListView listaAlunos = (ListView) findViewById(R.id.lista_alunos);
ArrayAdapter<String> adapter = new ArrayAdapter <String> (this, android.R.layout.simple_list_item_1, alunos);
listaAlunos.setAdapter(adapter);

Seu array de string tá com letra maiúscula

Excelente Vânia, obrigado pela dica e a solução do problema. Exatamente isso que você postou.

Grato!!!