Application flicker problem: it will flicker from the beginning of the parsing of json information

the function you want to achieve is to press the keyword to search after clicking the top button. You can already receive the feedback json information from the server, but it will flash from the beginning of the parsing of the json information, and loading listview does not know whether it is possible or not.

public abstract class loadlistview {

public ListView plv;
public String js;

public int listlength;
public int listvisit;
public int loadlength;

public void setloadlength(int i){
    this.loadlength=i;
}
public void setjs(String js){this.js=js;}
public void setplv(ListView plv){
    this.plv=plv;
}


public abstract void loadlv();
public abstract void addloadlv();

}

public class HomepageActivity extends AppCompatActivity {

public Button product;
public Button book;
public Button service;
public String weburl;
public String location;
public View loadmore;
public int last_index; 
public int total_index;
public jsonrequest jrq;
public loadproductlist newlpl;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_homepage);
    product = (Button) findViewById(R.id.hp_btn_product);
    book = (Button)findViewById(R.id.hp_btn_book);
    service = (Button)findViewById(R.id.hp_btn_service);
    //loadmore= View.inflate(HomepageActivity.this,R.layout.layout_loadmore,null);
    // ,
    //loadmore.setVisibility(View.GONE);

    weburl=this.getString(R.string.cfmheiaskin);
    location="keysearch.php";

    jrq=new jsonrequest();
    jrq.seturl(weburl);
    jrq.setLocation(location);

    newlpl=new loadproductlist();
    newlpl.setloadlength(6);
    newlpl.plv=(ListView) findViewById(R.id.hp_lv_pinfo);
    //newlpl.plv.addFooterView(loadmore,null,false);

    /*
    newlpl.plv.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView absListView, int i) {
            if(last_index == total_index && (i == AbsListView.OnScrollListener.SCROLL_STATE_IDLE))
            {
                //
                loadmore.setVisibility(View.VISIBLE);
                //
                newlpl.addloadlv();
            }
        }

        @Override
        public void onScroll(AbsListView absListView, int i, int i1, int i2) {
            last_index = i+i1;
            total_index = i2;

        }
    });
    */

    product.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            jrq.setkey("product");
            jrq.imgbtnclick();
            newlpl.setjs(jrq.getresult());
            newlpl.getArray();
            //newlpl.loadlv();
        }
    });

    book.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            jrq.setkey("book");
            jrq.imgbtnclick();
            Toast.makeText(HomepageActivity.this,jrq.getresult(),Toast.LENGTH_SHORT).show();
            //newlpl.setjs(jrq.getresult());
            //newlpl.getArray();
            //newlpl.loadlv();
            //imgdownload idl=new imgdownload();
            //idl.setpath("proimg/phone.jpg",weburl);
            //idl.imgloading();

        }
    });

    service.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            jrq.setkey("service");
            jrq.imgbtnclick();
            Toast.makeText(HomepageActivity.this,jrq.getresult(),Toast.LENGTH_SHORT).show();
            //newlpl.setjs(jrq.getresult());
            //newlpl.getArray();
            //newlpl.loadlv();

        }
    });

}
class loadproductlist extends loadlistview{
    public plvadapter newadapter;
    public proinfo[] pia;
    public List<proinfo> pil;


    public void getArray(){
        final Handler handler=new Handler(){
                @Override
        public void handleMessage(Message msg){
            // TODO Auto-generated method stub
            super.handleMessage(msg);
            if (msg.what == 1) {
                
                pia=(proinfo[]) msg.obj;
                listlength=pia.length;
                pil=new ArrayList<>(listlength);
            }
        }
        };
        new Thread(new Runnable() {
            @Override
            public void run() {
                String jstring=js;
                if(jstring==null){
                    Toast.makeText(HomepageActivity.this,"",Toast.LENGTH_SHORT).show();
                }else{
                    try {
                        JSONArray jarray=new JSONArray(jstring);
                        JSONObject jo;
                        int j=jarray.length();
                        proinfo[] newarray=new proinfo[j];
                        proinfo pi=new proinfo();
                        int i=0;
                        while(i<j){
                            jo=(JSONObject) jarray.get(i);
                            pi.name=jo.getString("p_name");
                            pi.price=jo.getString("price");
                            pi.issuer=jo.getString("p_sellor");
                            pi.imgurl=jo.getString("imgurl");
                            newarray[i]=pi;
                            i=i+1;
                        }
                        Message msg=new Message();
                        msg.obj=newarray;//
                        msg.what=1;
                        handler.sendMessage(msg);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }
            }
        }).start();
    }

    @Override
    public void loadlv() {

                for(listvisit=0;listvisit<listlength&&listvisit<loadlength;listvisit+=1){
                    pil.add(pia[listvisit]);
                }
                if(listvisit!=0){
                    newadapter= new plvadapter(HomepageActivity.this,pil);
                    plv.setAdapter(newadapter);
                }else{
                    Toast.makeText(HomepageActivity.this,"",Toast.LENGTH_SHORT);
                }


    }

    @Override
    public void addloadlv() {
        new Thread(
                new Runnable() {
                    @Override
                    public void run() {

                        try {
                            //
                            Thread.sleep(2000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }

                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                for(int j=listvisit;listvisit<listlength&&listvisit<j+loadlength;listvisit+=1){
                                    pil.add(pia[listvisit]);
                                }
                                if(listvisit!=0){
                                    newadapter.updateView(pil);
                                    //
                                    loadmore.setVisibility(View.GONE);
                                }else{
                                    Toast.makeText(HomepageActivity.this,"",Toast.LENGTH_SHORT);
                                }
                            }
                        });


                    }
                }).start();
    }


}

public class plvadapter extends BaseAdapter{
    List<proinfo> tlist;
    LayoutInflater inflater;
    imgdownload idl;

    public plvadapter(Context context, List<proinfo> list) {
        this.tlist=list;
        this.inflater=LayoutInflater.from(context);
        this.idl=new imgdownload();
    }

    @Override
    public int getCount() {
        return tlist.size();
    }

    @Override
    public Object getItem(int i) {
        return tlist.get(i);
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    public void updateView(List<proinfo> nowList){
        this.tlist=nowList;
        this.notifyDataSetChanged(); //getView
    }
    //@SuppressLint("InflateParams")
    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHoder;
        if(view ==null){
            viewHoder=new ViewHolder();
            view=inflater.inflate(R.layout.layout_productbox,null);
            viewHoder.img= view.findViewById(R.id.pbox_img_pro);
            viewHoder.name= view.findViewById(R.id.pbox_txv_name);
            viewHoder.price= view.findViewById(R.id.pbox_txv_price);
            viewHoder.issuer= view.findViewById(R.id.pbox_txv_issuer);
            view.setTag(viewHoder);

        }else {
            viewHoder=(ViewHolder)view.getTag();
        }
        idl.setpath(tlist.get(i).imgurl,weburl);
        idl.imgloading();
        viewHoder.img.setImageBitmap(idl.bmap);
        viewHoder.name.setText(tlist.get(i).name);
        viewHoder.price.setText(tlist.get(i).price);
        viewHoder.issuer.setText(tlist.get(i).issuer);
        return view;
    }
    }
    class  ViewHolder{
        ImageView img;
        TextView name;
        TextView price;
        TextView issuer;
    }
}
Mar.05,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e46042-44b8b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e46042-44b8b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?