2017-09-16 1 views
0

Meine ListView scrollt nicht mehr. Alles andere funktioniert gut, aber es scrollt gerade nicht. Es hat früher funktioniert. Ich denke, das Einzige, was ich hinzugefügt habe, war ein Floating-Action-Button und jetzt scrollt es nicht. Ich habe es auch programmatisch festgelegt, um die Listenansicht anzuzeigen oder nicht. Wer weiß, warum es nicht scrollt? HierListView scrollt nicht. Vielleicht, weil die Sichtbarkeit programmgesteuert oder eine Floating-Aktion-Schaltfläche ist?

ist das Layout:

 <?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    > 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginStart="10dp" 
      android:layout_marginTop="10dp" 
      android:src="@drawable/ic_search_black_24dp"/> 
     <EditText 
      android:id="@+id/etSearchZip" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="3" 
      android:layout_marginTop="10dp" 
      android:imeOptions="actionSearch" 
      android:inputType="number"/> 
    </LinearLayout> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/no_leads_found" 
     android:layout_marginLeft="10dp" 
     android:layout_marginStart="10dp" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="2" 
      android:textSize="20sp" 
      android:padding="15dp" 
      android:text="@string/lead_name" 
      android:textStyle="bold" 
      /> 
     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:id="@+id/tvDatePosted" 
      android:text="@string/posted" 
      android:textSize="20sp" 
      android:padding="15dp" 
      android:textStyle="bold" 
      /> 
    </LinearLayout> 

    <TextView 
     android:id="@+id/tvNoLeadsFound" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/no_leads_found" 
     android:gravity="center" 
     android:visibility="gone"/> 

    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:textSize="16sp" 
     android:id="@+id/browseAgentsLV" /> 
</LinearLayout> 

Und hier ist die entsprechende Java für das Fragment (es in onCreateView genannt):

ListAdapter listAdapter = new RowAdapter(getActivity(), leadMapList); 

        listView.setAdapter(listAdapter); 
        listView.setOnItemClickListener(new 
                  AdapterView.OnItemClickListener() { 
                   @Override 
                   public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 
                    String agentPicked = "You selected " + String.valueOf(parent.getItemAtPosition(position)); 
                    Toast.makeText(getActivity(), agentPicked, Toast.LENGTH_SHORT).show(); 
                   } 
                  }); 
        noLeadsFound.setVisibility(view.GONE); 
        listView.setVisibility(view.VISIBLE); 

Antwort

0

Vielleicht haben Sie nicht genug Artikel in Ihrem ListView? Wie schon gesagt, können Sie RecyclerView verwenden. Es ist eine flexiblere Version von ListView.

Hier sind die Führungen:

https://developer.android.com/guide/topics/ui/layout/recyclerview.html https://developer.android.com/training/material/lists-cards.html

Und hier ist Beispiel: Simple Android RecyclerView example

+0

Das Problem war nur, dass die Abfrage eine innere hatten verbinden und zurückkehrte weniger Zeilen als ich dachte. Zuvor gab die Abfrage mehr Zeilen zurück, aber sobald die Abfrage geändert wurde, wurden zu wenige Zeilen zurückgegeben, um den Bildlauf zu ermöglichen. –

0

, die nicht funktionieren! Verwenden Sie eine RecyclerView anstelle einer ListView und verwenden Sie eine NestedScrollView als übergeordneten übergeordneten Parameter von LinearLayout.

Verwandte Themen