ExpandableList is hidden initially

0

Every time I start the activity with the ExpandableList it is hidden, so I have to press the shutdown button and restart it so it shows.

How do I resolve this?

My ExpandableList

<ExpandableListView
        android:id="@+id/lvExp"
        android:layout_width="match_parent"
        android:layout_height="450dp"
        android:layout_weight="1"/>

EDITION

All of my Layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:background="@color/colorCorpo"
    android:orientation="vertical"
    tools:context="ham.org.br.nutricao.activity.CardapioActivity">

    <include
        android:id="@+id/toolbarCardapio"
        layout="@layout/toolbar" />
    <ExpandableListView
        android:id="@+id/lvExp"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        />

    <Button
        android:id="@+id/btn_acao"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Button" />


</LinearLayout>

Activity

protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.cardapio_activity);
     expListView = ( ExpandableListView ) findViewById( R.id.lvExp );
     toolbar = (Toolbar) findViewById( R.id.toolbarCardapio );
     toolbar.setTitle( "Cardápio" );
     setSupportActionBar( toolbar );

     listAdapter = new ExpandableListAdapter( this, listGrupo, listaItem );
     //setando list adapter
     expListView.setAdapter( listAdapter );
     int idTipoRef = bundle.getInt( "tipo" );
     String data   = bundle.getString( "data" );
     chamarTipoPratos( service, idTipoRef, data );

}

private void chamarTipoPratos( Service service, int idTipoRef, String data ){
        listGrupo = new ArrayList<String>();
        listaItem = new HashMap<String, List<String>>();
        listIngredientes = new HashMap<String, String>();
        listIngrediente = new ArrayList<String>();
        final Call<List<TipoPrato>> listTipoPratos = service.getlistTipoPratos("R", idTipoRef, data);
        listTipoPratos.enqueue( new Callback<List<TipoPrato>>() {
            @Override
            public void onResponse(Call<List<TipoPrato>> call, Response<List<TipoPrato>> response) {
           //     Log.i("onResponse TipoPratos",response.toString());

                if( response.isSuccessful() ){
                    List<TipoPrato> tipoPratos = response.body();
                    int i = 0;
                    for( TipoPrato tipoPrato : tipoPratos ){

                        //Log.i("Tipo", tipoPrato.getTipoprato());
                        ArrayList<Prato> listaPratos = tipoPrato.getPratoList();

                        listGrupo.add(tipoPrato.getTipoprato());
                        ArrayList<String> pratos = new ArrayList<String>();
                        ArrayList<String> ingredientes = new ArrayList<String>();

                        for ( Prato prato : listaPratos ){
                       //     Log.i("Pratos", prato.getPrato());
                            pratos.add( prato.getPrato() );
                            ingredientes.add( prato.getIngrediente() );
                            listIngredientes.put( prato.getPrato(), prato.getIngrediente() );
                        }

                        listaItem.put( listGrupo.get( i ), pratos );

                        i++;

                }

            }
            }

            @Override
            public void onFailure(Call<List<TipoPrato>> call, Throwable t) {
                Log.i("onFailure TipoPrato", t.getMessage());
            }
        });
    }
    
asked by anonymous 09.08.2017 / 16:53

1 answer

1

I've seen three options that may be making this happen, probably the visibility of the parent layout is as gone or invisible, may have some layout above the View, or the initialization of the ExpandableListView or the parent layout within the activity or fragment, is being gone or invisible.

    
09.08.2017 / 18:25