1.我在mainactivity建了一个空的内部类
Response response = okHttpClient.newCall (request).execute ();
String date = response.body ().string ();
Gson gson = new Gson ();
F_User f_user = gson.fromJson (date, F_User.class);
```
这样是不是就能创建,并且给F_User这个类的对象赋值
2.接着怎么显示在页面不知道咋做,
``` if (date != null) {
Gson gson = new Gson ();
F_User f_user = gson.fromJson (date, F_User.class);
//把解析好的数据发送到页面
TextView tv_id = findViewById (R.id.tv1);
tv_id.setText(f_user.getF_id ());
TextView tv_name = findViewById (R.id.tv2);
tv_name.setText(f_user.getF_username ());
TextView tv_group = findViewById (R.id.tv3);
tv_group.setText(f_user.getF_group ());
TextView tv_role = findViewById (R.id.tv4);
tv_role.setText(f_user.getF_role ());
TextView tv_role_index = findViewById (R.id.tv5);
tv_role_index.setText(f_user.getF_role_index ());
TextView tv_passcode = findViewById (R.id.tv6);
tv_passcode.setText(f_user.getF_passcode ());
//加入message
Message message = new Message ();
message.what =1;
handler.sendMessage (message);
public Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 1://_这个位置写的对吗_
*_ BaseAdapter adapter=new BaseAdapter () {
}
(this,R.layout.activity_main);
.setAdapter();
break_;*
}
```是这个样子就可以了吗?
3.下面是我copy的模板地址
[引用地址](https://blog.csdn.net/qq_26650589/article/details/70256219 "A")
因为数据格式变了,导致项目解析数据之后的步骤不知道还需要不,想用ListView接,因为刚接触安卓,拖控件也拖不明白,辛苦大神们了。