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"?
– ramaral
The button on the phone. The one that blocks the screen
– adventistaam