0

quisiera mostrar 3 listview uno al lado del otro parecido a la imagen de abajo y se deslize horizontalmente para ver los demás listview.

introducir la descripción de la imagen aquí

activity_main.xml

<?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"
    tools:context=".MainActivity">


    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardCornerRadius="20dp"
        android:layout_margin="8dp">




        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="10dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Encabezado"
                    android:textSize="18dp"/>
            </LinearLayout>



                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical">

                    <ListView
                        android:id="@+id/listview"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        >

                    </ListView>


                </LinearLayout>






        </LinearLayout>




    </android.support.v7.widget.CardView>

</LinearLayout>

MainActivity.java

public class MainActivity extends AppCompatActivity {


    ListView lstDias;
    Button btnPostYourEnquiry;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        lstDias = (ListView) findViewById(R.id.listview);

        ArrayList<String> listaNombres = new ArrayList<>();
        listaNombres.add("Juan");
        listaNombres.add("Juan");
        listaNombres.add("Juan");
        listaNombres.add("Juan");



        ArrayAdapter adapter =  new ArrayAdapter(this,android.R.layout.simple_list_item_1,listaNombres);
        lstDias.setAdapter(adapter);


        FrameLayout footerLayout = (FrameLayout) getLayoutInflater().inflate(R.layout.footer,null);
        btnPostYourEnquiry = (Button) footerLayout.findViewById(R.id.btnGetMoreResults);
        lstDias.addFooterView(footerLayout);

    }
}

footer.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/btnGetMoreResults"
        android:layout_marginLeft="10px"
        android:text="Agregar"
        android:drawableLeft="@drawable/ic_add_black_24dp"
        style="@style/Base.Widget.AppCompat.Button.Borderless"/>
</FrameLayout>
1
  • 1
    El primer layout debería tener una posición horizontal android:orientation="horizontal", y luego, dentro de éste, puedes meter los otros 3 en vertical
    – Mimmetico
    el 23 ene. 2019 a las 17:07

1 respuesta 1

0

Asumiendo que quieres que los 3 tengan el mismo tamaño solo debes incluirlos en un LinearLayout con orientacion horizontal

 <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">
            <ListView
                android:id="@+id/listview1"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1" />
            <ListView
                android:id="@+id/listview2"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1" />
            <ListView
                android:id="@+id/listview3"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1" />
        </LinearLayout>
1
  • Solo se muestra un listview
    – Darwin
    el 23 ene. 2019 a las 17:39

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.