Fragement 代码 listview展示Gson解析

1.判断

   listView = view.findViewById(R.id.listview);
               if (Http.isNetWord(getActivity())){
                MyAsyncTask myAsyncTask = new MyAsyncTask();
                myAsyncTask.setBacks(this);
                myAsyncTask.execute("http://api.expoon.com/AppNews/getNewsList/type/1/p/1" );
               }else {
                 Toast.makeText(getActivity(), "无网络连接", Toast.LENGTH_SHORT).show();
               }

2.解析

  @Override
        public void getData(String s) {
            Gson gson = new Gson();
            Josnbean josnbean = gson.fromJson(s, Josnbean.class);
            List data = josnbean.getData();
            Toast.makeText(getActivity(), ""+ this.data, Toast.LENGTH_SHORT).show();
           listView.setAdapter(new MyAdapter(data,getActivity()));
    
        }

你可能感兴趣的:(Fragement 代码 listview展示Gson解析)