recyclerview获得网络请求的数据显示不出来的问题

try {
    jsonArray = new JSONArray( s0);
    for(int i=0;i< 10;i++){
        JSONObject jsonObject=jsonArray.getJSONObject( i );
        String ss=jsonObject.getString( "orderNum" );
        String s1=jsonObject.getString( "tradeName" );
        String s3= jsonObject.getString( "contactName" );
        String s4="lainxinren"+ss;
        Dingdan dingdan=new Dingdan( s4,R.drawable.timg );
        list.add(dingdan );
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                //创建适配器
                RecyclerView recyclerView=(RecyclerView)findViewById( R.id.recyclerview );
                LinearLayoutManager linearLayoutManager=new LinearLayoutManager( Main2Activity_show.this );
                recyclerView.setLayoutManager( linearLayoutManager );
                DingdanAdapter adapter=new DingdanAdapter( list );
                // adapter.setHasStableIds(true);//数据加载
                recyclerView.setAdapter( adapter );
            }
        });
    }

新开一个runnable就可以了

 

你可能感兴趣的:(recyclerview获得网络请求的数据显示不出来的问题)