proxiesArrayList时丢失了。 它给我红色字体并给出此错误。
错误:proxiesArrayList在ServerListModel中不是公共的;不能从外包装中访问
ProxyApiService apiService = ((BrowserApp)getApplicationContext()).getService();
Call<ServerListModel> serviceCall = apiService.listOfServers();
serviceCall.enqueue(new Callback<ServerListModel>() {
@Override
public void onResponse(Call<ServerListModel> call, Response<ServerListModel> response) {
ArrayList<Proxies> proxyArrayList = response.body().proxiesArrayList;
Log.e(TAG,response.body()+"123");
}
@SuppressLint("LongLogTag")
@Override
public void onFailure(Call<ServerListModel> call, Throwable t) {
Log.e(TAG, t.toString());
}
});
我的ServiceModel类
@Root(name = "serverlist")
public class ServerListModel {
@ElementList(inline = true)
ArrayList<Proxies> proxiesArrayList;
}
答案 0 :(得分:0)
更改此:
ArrayList<Proxies> proxiesArrayList;
对此:
public ArrayList<Proxies> proxiesArrayList;
或更妙的是,将其更改为:
private ArrayList<Proxies> proxiesArrayList;
然后创建一个公共获取器和设置器。
public void setProxies(ArrayList<Proxies> proxies){
this.proxiesArrayList = proxies;
}
public ArrayList<Proxies> getProxies(){
return this.proxiesArrayList;
}