Expandablelist comes hidden initially

Asked

Viewed 39 times

0

Every time I start Activity with Expandablelist comes hidden, then I have to press the off button and turn it on so it shows.

How do I fix it?

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());
            }
        });
    }
  • What’s this "off and on button"?

  • The button on the phone. The one that blocks the screen

1 answer

1


I saw three options that might be making this happen, probably the visibility of the parent layout is like Gone or Invisible, may have some layout over the View,or the initialization of Expandablelistview or the parent layout within Activity or Fragment, is being Gone or Invisible.

  • how do I find this?

  • 1

    Checks in your XML which parent View or then reissues your post by writing all Expandablelistview XML

  • I’ve already edited with all the Activity xml

  • Could you paste your code too ? Remove the Weigth as no division is required.

  • I put the code in general

  • Okay, nothing’s showing up, just because you’re not referencing your layout, so you have to override the onCreate method. Below onCreate you add this two lines of super.onCreate(savedInstanceState); setContentView(R.layout.nameeulayout); //Put the name of your layout here for it to be referenced, where is R.layout.eulayout you place the layout that is using Expandablelist

  • I made a new edition to show how is the beginning of my onCreate

  • It’s working normally, only at the beginning it comes as if it was hidden, then if I press the button lock the screen of the phone and unlock the screen, it appears

  • Any idea what it might be?

  • You can show the part of the code of "On" and "Off" the button on click ?

  • was the button of the same cell phone

  • Wonder =) good that solved your problem.

  • actually I had to call the call IpoPratos( service, idTipoRef, date ); within the method itself and I was calling after the call of the method

Show 8 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.