View Scroll Not Smooth List

I have my own list view, which displays users, and there photos I extract data from the API, which gives JSON output,

My problem is that the list view does not scroll smoothly, it freezes for a second and scrolls, it repeats until we reach the end.

I thought this could be because I am performing a network operation on a user interface thread, but it continues to do this even after the download is complete?

structure of my custom Listview

 <TextView  style="@style/photo_post_text"
             android:id="@+id/photo_post_text"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:text="demotext"
           />


        <ImageView
            android:id="@+id/userimage"
           android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scaleType="fitXY"

            android:adjustViewBounds="true"
           android:src="@drawable/pi" 
           />
+4
source share
3 answers

AsyncTask . , .

. , . , , , "" . , . ConcurrentHashMap, .

+7

, https://github.com/bumptech/glide

strictMode.IT onCreate()

protected void onCreate(Bundle savedInstanceState) {

    //StrictMode for smooth list scroll
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    /*----- 
        ListView 
        Custom Adapter set data....
    ------*/}

onCreate()

listView.setOnScrollListener(new OnScrollListener() {
public void onScroll(AbsListView view, int firstVisibleItem,int visibleItemCount, int totalItemCoun) {
}
public void onScrollStateChanged(AbsListView view, int scrollState) {
        if (scrollState != 0)
            listView.getAdapter()).isScrolling = true;
        else {
            adapter.isScrolling = false;
            adapter.notifyDataSetChanged();
        }
} });

public static Boolean isScrolling = true;
+3

ListView. , ,

  • Holder getView()
  • , ListView? .
  • AsyncTask JSON , .

Once you are convinced that you wrote above, it should work well.

+2
source

All Articles