0

I have a List View thatis retrived from a php that get's it from MySql. However,when a retice the data that does not match the simple adater that I formated. Here is my code:

''HashMap map = new HashMap();

                map.put(TAG_VALOR, valorIntent);
                map.put(TAG_COMIDA ,  Scomida);
                map.put(TAG_TABACO ,  Stabaco);
                map.put(TAG_BEBIDAS ,  Sbebidas);
                map.put(TAG_SABADO ,  Ssabado);
                map.put(TAG_DOMINGO ,  Sdomingo);
                map.put(TAG_HIGIROUP ,  Shigiroup);
                map.put(TAG_MULTIBANCO ,  Smultibanco);
                map.put(TAG_OUTROS ,  Soutros);


                productsList.add(map);
           }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }



    protected void onPostExecute(String file_url) {
        // dismiss the dialog after getting all products
        pDialog.dismiss();
        // updating UI from Background Thread
        runOnUiThread(new Runnable() {
            public void run() {



                ListAdapter adapter = new SimpleAdapter(
                        Relatorio.this, productsList,
                        R.layout.relatorio_details, new String[] { TAG_COMIDA,TAG_TABACO,TAG_BEBIDAS,TAG_SABADO
                        ,TAG_DOMINGO,TAG_HIGIROUP, TAG_MULTIBANCO, TAG_OUTROS},
                        new int[] { R.id.comidaRel,  R.id.tabacoRel,R.id.bebidasRel, R.id.sabadoRel
                                , R.id.domingoRel, R.id.higroupasRel, R.id.multibancoRel, R.id.outrosRel});
                setListAdapter(adapter);


                Log.d("Multibanco", TAG_MULTIBANCO);
            }
        });'

and this is the relatorio_details wrapped in LinearLayout vertical:

'<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:layout_weight="1">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:text="Comida"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:id="@+id/comidaRel"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:layout_weight="1">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:text="Tabaco"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:id="@+id/tabacoRel"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:layout_weight="1">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:text="Multibanco"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:id="@+id/multibancoRel"
        android:text="0.00"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:layout_weight="1">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:text="Bebidas"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:id="@+id/bebidasRel"
        android:text="0.00"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:layout_weight="1">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:text="Sábado"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:id="@+id/sabadoRel"
        android:text="0.00"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:layout_weight="1">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:text="Domingo"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:id="@+id/domingoRel"
        android:text="0.00"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:layout_weight="1">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:text="Higiene e Roupas"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:id="@+id/higroupasRel"
        android:text="0.00"/>

</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:layout_weight="1"
    android:id="@+id/outros_rel">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:text="Outros"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:id="@+id/outrosRel"
        android:text="0.00"/>

</LinearLayout>

The data shows but does not respect the relatorio_details Layout

Jose Borges
  • 340
  • 2
  • 4
  • 14

1 Answers1

0

You need to make a custom adapter class for your list view nad a custom layout that is a simple xml layout file after that you need to set the adapter of your list view ListView.setAdapter(new CustomAdapter(datalist)); Use this link for more help Custom Adapter for List View

Community
  • 1
  • 1