我不知道这个问题,如何解决这个问题这是我在android工作室的片段代码。可能因为frgament或recycleviewadapter中的其他内容而无法获取数据。因为这个错误给了recycleviewadapter。同学们,这是我的片段。
AndroidNetworking.get("http://xxxxxxxx/driverapps/getData.php")
.setTag("Get Data")
.setPriority(Priority.MEDIUM)
.build()
.getAsJSONObject(new JSONObjectRequestListener() {
@Override
public void onResponse(JSONObject response) {
progressDialog.dismiss();
try{
Boolean status = response.getBoolean("status");
if(status){
JSONArray ja = response.getJSONArray("result");
Log.d("respon",""+ja);
for(int i = 0 ; i < ja.length() ; i++){
JSONObject jo = ja.getJSONObject(i);
array_noinduk.add(jo.getString("noinduk"));
array_nama.add(jo.getString("nama"));
array_alamat.add(jo.getString("alamat"));
array_hobi.add(jo.getString("hobi"));
}
recycleViewAdapter = new RecycleViewAdapter(getContext(),array_noinduk,array_nama,array_alamat,array_hobi);
rv_main.setAdapter(recycleViewAdapter);
}else{
Toast.makeText(getActivity(), "Gagal Mengambil Data", Toast.LENGTH_SHORT).show();
recycleViewAdapter = new RecycleViewAdapter(getContext(),array_noinduk,array_nama,array_alamat,array_hobi);
rv_main.setAdapter(recycleViewAdapter);
}
}
catch (Exception e){
e.printStackTrace();
}
}
这是我的recycleviewadapter,((homemenu)mcontext).startactivityforresult(i,2);让我从这个类的错误代码,如何解决这个错误?
public void onBindViewHolder(MyViewHolder holder, final int position) {
holder.tv_noind.setText(array_noinduk.get(position));
holder.tv_nama.setText(array_nama.get(position));
holder.tv_alamat.setText(array_alamat.get(position));
holder.tv_hobi.setText(array_hobi.get(position));
holder.cv_main.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(mContext,RoomActivity.class);
i.putExtra("noinduk",array_noinduk.get(position));
i.putExtra("nama",array_nama.get(position));
i.putExtra("alamat",array_alamat.get(position));
i.putExtra("hobi",array_hobi.get(position));
((HomeMenu)mContext).startActivityForResult(i,2);
}
});
}
我不知道怎么解决这个问题
暂无答案!
目前还没有任何答案,快来回答吧!