我的对话框关闭
if (status.equals("true")) {
Toast.makeText(context, "" + msg, Toast.LENGTH_LONG).show();
notifyDataSetChanged();
dialog.dismiss();
}
我使用了notifyDataSetChanged(),但Fragment布局仍未刷新或未更新
Adapter.java
holder.txt_payRef_update.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (orderlistArrayList.get(position).getPaymentStatus().equals("0")) {
final Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_payment_reference);
Window window = dialog.getWindow();
window.setLayout(Toolbar.LayoutParams.FILL_PARENT, Toolbar.LayoutParams.WRAP_CONTENT);
final TextView txt_orderId = (TextView) dialog.findViewById(R.id.txt_orderId);
final TextView txt_total_amount = (TextView) dialog.findViewById(R.id.txt_total_amount);
final TextView txt_doPayment = (TextView) dialog.findViewById(R.id.txt_doPayment);
final TextView edtxt_order_referenece_id = (EditText) dialog.findViewById(R.id.edtxt_order_referenece_id);
txt_orderId.setText("Order ID " + orderlistArrayList.get(position).getOrderId());
txt_total_amount.setText("Total Due Amount " + (context.getResources().getString(R.string.Rs)) + orderlistArrayList.get(position).getTotalPrice());
edtxt_order_referenece_id.setText(orderlistArrayList.get(position).getPayRef());
txt_doPayment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String Reference_Id = edtxt_order_referenece_id.getText().toString();
if (!Reference_Id.equalsIgnoreCase("")) {
DoUpdatePaymentRef(orderlistArrayList.get(position).getOrderId(), Reference_Id);
// Toast.makeText(context,“ Done !!”,Toast.LENGTH_LONG).show(); // dialog.dismiss(); }其他{ Toast.makeText(context,“ Please Put Order Reference ID !!”,Toast.LENGTH_LONG).show();
}
}
private void DoUpdatePaymentRef(String orderId, String reference_id) {
progress = new ProgressDialog(context);
progress.setMessage("Please Wait..");
progress.setCancelable(false);
progress.show();
JSONObject params = new JSONObject();
try {
params.put("orderId", orderId);
params.put("payRef", reference_id);
} catch (JSONException e) {
e.printStackTrace();
}
System.out.println("Params orderPayRefUpdate--> " + params.toString());
System.out.println(" URL_orderPayRefUpdate--> " + Constant.orderPayRefUpdate);
JsonObjectRequest jsonArrayRequest = new JsonObjectRequest(Request.Method.POST, Constant.orderPayRefUpdate, params,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
String status = "";
progress.dismiss();
System.out.println("orderPayRefUpdate Response -->" + response.toString());
try {
JSONObject objStatus = new JSONObject(response
.toString());
status = objStatus.getString("valid");
String msg = objStatus.getString("msg");
if (status != null && !status.equalsIgnoreCase("")) {
if (status.equals("true")) {
Toast.makeText(context, "" + msg, Toast.LENGTH_LONG).show();
// adapter.notifyDataSetChanged(); dialog.dismiss();
} else {
Toast.makeText(context, "" + msg, Toast.LENGTH_LONG).show();
}
}
} catch (JSONException e) {
progress.dismiss();
e.printStackTrace();
//Toast.makeText(PersonalInfo_QRActivity.this, "e." + e.toString(), Toast.LENGTH_SHORT).show();
}
}
}, new Response.ErrorListener() {
public void onErrorResponse(VolleyError error) {
System.out.println("Error : " + error.toString());
}
});
jsonArrayRequest.setRetryPolicy(new DefaultRetryPolicy(
30000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
VolleySingleton.getInstance(context).getRequestQueue()
.add(jsonArrayRequest);
}
});
dialog.show();
}
}
});
Fragment.java
adapterOrderList = new AdapterOrderList(getActivity(), orderlistArrayList);
adapterOrderList.notifyDataSetChanged();
grid_view_fragment.setAdapter(adapterOrderList);
答案 0 :(得分:0)
更新后,您应该更新orderlistArrayList
例如,如果您想更新在此编辑文本edtxt_order_referenece_id
中输入的文本,则应从编辑文本中获取原始值,并应在项目位置orderlistArrayList.get(position).setPayRef(edtxt_order_referenece_id.getText().toString())
对其进行更新< / p>
完成后,应致电notifyDataSetChanged();
或notifyItemChanged(position);