我已经定义了单独的适配器类,获取器和设置器。
任何人都可以帮助清除错误吗?
谢谢。
这是使用回收者视图的类。单独的卡片视图已附加到回收站
public class boxInService extends AppCompatActivity {
RecyclerView recyclerView;
inserviceAdapter inadapter;
List<serviceData> serviceDataList;
ProgressDialog progressDialog;
private SharedPreferences pref;
private static final String PREF_NAME="share_pref";
String op;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_box_in_service);
getSupportActionBar().setTitle("Boxes in Service");
serviceDataList=new ArrayList<>();
recyclerView=findViewById(R.id.in_service_recycler);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
pref=getSharedPreferences(PREF_NAME,MODE_PRIVATE);
op=pref.getString("operator_stored","");
progressDialog=new ProgressDialog(this);
progressDialog.setMessage("Loading....");
progressDialog.show();
loadData();
}
private void loadData() {
StringRequest request=new StringRequest(
Request.Method.GET,
ROOT_URL + boxinService + op,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
progressDialog.dismiss();
try {
JSONArray jsonArray=new JSONArray(response);
for (int i=0;i<=jsonArray.length();i++){
JSONObject object=jsonArray.getJSONObject(i);
String chip=object.getString("chip_id");
String ua=object.getString("ua_key");
String cas=object.getString("cas");
String model=object.getString("stb_type");
serviceData s_Data=new serviceData(chip,ua,cas,model);
serviceDataList.add(s_Data);
}
inadapter=new inserviceAdapter(boxInService.this,serviceDataList);
recyclerView.setAdapter(inadapter);
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
progressDialog.hide();
Toast.makeText(getApplicationContext(),error.getMessage(),Toast.LENGTH_SHORT).show();
}
}
);
VolleyRequest.getInstance(this).addToRequest(request);
}
}
有什么遗漏吗?