0

My ListView no longer scrolls. Everything else works just fine but it just doesn't scroll now. It used to work. I think the only thing I added was a floating action button and now it does not scroll. I also made it programmatically determine to display the list view or not. Anyone know why it isn't scrolling?

Here is the 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>

And here is the relevant java for the fragment (it's called in onCreateView):

 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);
jmbauerful
  • 34
  • 8

2 Answers2

1

Maybe you don't have enough items in your ListView?

As already said you can use RecyclerView. It is more flexible version of ListView.

Here are the guides:

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

And here is example: Simple Android RecyclerView example

Shunt
  • 179
  • 8
  • The issue was just that the query had an inner join and was returning less rows than I thought. Previously the query returned more rows but once the query changed it returned too few rows to allow the scroll. – jmbauerful Sep 19 '17 at 01:52
0

That won't work! Try using a RecyclerView instead of a listView and use a NestedScrollView as the overall parent of the LinearLayout.

Idee
  • 1,887
  • 21
  • 31