2017-07-23 3 views
0

Hallo alle zuerst ich Englisch ist schlecht, so werde ich mein bestes tun, um zu entwickeln, was ich in meinem listview tun möchte.Wie man split listview macht

sowieso ich habe eine listeansicht, ich muss in zwei seiten teilen. (links - rechts) wie dieses Bild ein Beispiel ----->https://ibb.co/dotxS5

das ist meine Layout-Code.

<?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="com.tasneem.coustomlistview.MainActivity"> 

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

</LinearLayout> 

Code eingeben hier

und das ist mein Reihen Layout

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
<ImageView 
    android:id="@+id/Image" 
    android:layout_width="120dp" 
    android:layout_height="120dp" 
    android:src="@mipmap/ic_launcher" 
    android:layout_marginStart="15dp" 
    android:layout_marginTop="24dp" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentStart="true" /> 
    <TextView 
     android:id="@+id/name" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="name" 
     android:textSize="25dp" 
     android:layout_alignBottom="@+id/Image" 
     android:layout_toEndOf="@+id/Image" 
     android:layout_marginStart="38dp" /> 

</RelativeLayout> 

Ich möchte nur die oben folgenden in Layout tun.

Vielen Dank.

Antwort

1

Verwenden Sie RecyclerView anstelle von ListView.

Mit RecyclerView können Sie ganz einfach ein Raster mit GridLayoutManager erstellen.

myRecyclerView.setLayoutManager(new GridLayoutManager(context, numberOfColumns); 
myRecyclerView.setAdapter(myAdapter); 
+0

Bruder können Sie mir helfen? –

+0

Bruder können Sie mir helfen.? Ich habe das gleiche in GridLayoutManager gemacht und es funktioniert gut. Aber wie soll es so in staggerLayout sein? Ich habe es mit staggerLayout gemacht und die Bilder scheinen genauso wie Grid nichts anderes zu sein. –