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

Titulo da Aplicação e primeira linha não aparecem

Quando rodo a aplicação o Titulo "Agenda" ou "Formulario" nao aparecem no emulador, assim também como a primeira linha. Alguém pode ajudar?

20 respostas

Ana, coloca o código aqui?

package com.example.anacaroline.agenda;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class FormularioActivity extends AppCompatActivity {

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

        Button botaoSalvar = (Button) findViewById(R.id.formulario_salvar);
        botaoSalvar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(FormularioActivity.this, "Botao clicado", Toast.LENGTH_SHORT). show();
            }
        });
    }
}

coloca o código do layout e do AndroidManifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.anacaroline.agenda">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".ListaAlunosActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">

        </activity>
        <activity
            android:name=".FormularioActivity"
            android:label="@string/title_activity_formulario"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
<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"/>


</LinearLayout>

No teu manifest tu colocou um tema que não mostra a actionBar que é onde o título aparece.

android:theme="@style/AppTheme.NoActionBar"

exclui essa declaração das duas activitys. Outra coisa, teu plicativo é pra iniciar na Lista de alunos, então tu coloca isso dentro da tua activity ListaAlunosActivity:


        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

O

android.intent.action.MAIN

diz que essa activity é tua main, quando tu iniciar o app ela vai ser criada e o

android.intent.category.LAUNCHER

diz que essa tua activity será mostrada assim que for iniciada

é pra ficar assim:

        <activity
            android:name=".ListaAlunosActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".FormularioActivity"
            android:label="@string/title_activity_formulario">
    </activity>

Ana Caroline , conseguiu resolver?

Muito obrigada! Fiz as modificaçoes, no Android Studio não acusa erros, mas nos dois Emuladores que tentei aparece a mensagem "Unfurtunately, Agenda has stopped".

Copia o erro que aparece no teu logcat aqui


10/22 18:05:28: Launching app
$ adb shell am start -n "com.example.anacaroline.agenda/com.example.anacaroline.agenda.ListaAlunosActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 3928 on device emulator-5554
W/System: ClassLoader referenced unknown path: /data/app/com.example.anacaroline.agenda-1/lib/x86_64
I/InstantRun: Instant Run Runtime started. Android package is com.example.anacaroline.agenda, real application class is null.
W/System: ClassLoader referenced unknown path: /data/app/com.example.anacaroline.agenda-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/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.example.anacaroline.agenda, PID: 3928
                  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.anacaroline.agenda/com.example.anacaroline.agenda.ListaAlunosActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                      at android.app.ActivityThread.-wrap11(ActivityThread.java)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:148)
                      at android.app.ActivityThread.main(ActivityThread.java:5417)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                   Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
                      at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:347)
                      at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:316)
                      at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:281)
                      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                      at com.example.anacaroline.agenda.ListaAlunosActivity.onCreate(ListaAlunosActivity.java:19)
                      at android.app.Activity.performCreate(Activity.java:6237)
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                      at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                      at android.os.Handler.dispatchMessage(Handler.java:102) 
                      at android.os.Looper.loop(Looper.java:148) 
                      at android.app.ActivityThread.main(ActivityThread.java:5417) 
                      at java.lang.reflect.Method.invoke(Native Method) 
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
solução!

Acho que tá sem o theme do app no Manifest, confere se teu manifest ta assim:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.anacaroline.agenda">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        android:supportsRtl="true">
        <activity
            android:name=".ListaAlunosActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".FormularioActivity"
            android:label="@string/title_activity_formulario">
    </activity>
    </application>

</manifest>

e em especial se tem isso:

android:theme="@style/AppTheme"

Bingo Vânia! Obrigada!!

\o/

Help Vania! rsrs Fui rodar e reparei que no meu formulario, existe uma barra azul que cobre o primeiro item a ser preenchido "Nome", que fica logo abaixo do titulo da aplicação.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.anacaroline.agenda">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        android:supportsRtl="true">
        <activity
            android:name=".ListaAlunosActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".FormularioActivity"
            android:label="@string/title_activity_formulario">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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:fitsSystemWindows="true"
    tools:context="com.example.anacaroline.agenda.FormularioActivity">

    <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>

    <include layout="@layout/content_formulario" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:srcCompat="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>

Primeiro o teu Manifest tem que ter apenas um Laucher e um Main

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.anacaroline.agenda">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        android:supportsRtl="true">
        <activity
            android:name=".ListaAlunosActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".FormularioActivity"
            android:label="@string/title_activity_formulario">
        </activity>
    </application>

</manifest>

é pra ficar assim

Quando tu foi criar a Activity do formulário tu deve ter criado uma Basic Activity e era pra ter criado uma ``` Empty Activity

Pra tu resolver isso tu vai precisar mudar o códido  da activity_formulario pra isso:

<?xml version="1.0" encoding="utf-8"?>

```

e apagar esse

content_formulario.xml

olha se resolve

Vania, resolvi começar tudo de novo pois foi isso mesmo que aconteceu, escolhi a Basic ao invés de Empty. Na versão do AS da época que o vídeo foi gravado a função Empty era chamada Blank, e isso me levou ao erro. Mas foi bom pra eu rever o conteudo. obrigada :)))))

Ahhhh! E todos aqueles problemas que tive usando o Basic nao ocorrer mais x)

Ahhhh! E todos aqueles problemas que tive usando o Basic nao ocorreram mais x)