私は警告ダイアログボックスを持っています。私はリストitem.itのクリックで警告ダイアログを表示するfine.but私は後ろのボタンを押して警告ダイアログボックスは、私がクリックしたときに警告ダイアログボックスを閉じることができます電話からの戻るボタン。フラグメント内の戻るボタンをクリックするとアラートダイアログボックスを閉じることはできますか?
これは私のアダプタクラスである: -
public class PgListAdapter extends RecyclerView.Adapter<PgListAdapter.FaqViewHolder> {
private Context mContext;
private List<Faq> faqList1;
private ValueAnimator mAnimator;
private int updatePosition = -1;
private int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
private int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
private Faq ci;
private PopupWindow popupWindow;
public PgListAdapter(Context context, List<Faq> faqList) {
mContext = context;
this.faqList1 = faqList;
}
@Override
public FaqViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_pglist, parent, false);
FaqViewHolder vh = new FaqViewHolder(v);
return vh;
}
@Override
public void onBindViewHolder(final FaqViewHolder holder, int position) {
ci = faqList1.get(position);
holder.questionTv.setText(ci.getQuestion());
holder.answerTextView.setText(ci.getAnswer());
holder.Phone.setText(ci.getPhone());
holder.pgAddress.setText(ci.getAddress());
holder.ll_top.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showFilter();
}
});
holder.Phone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + holder.Phone.getText()));
mContext.startActivity(intent);
}
});
if (ci.isPGFull()) {
holder.pgstatus.setVisibility(View.VISIBLE);
} else {
holder.pgstatus.setVisibility(View.INVISIBLE);
}
}
@Override
public int getItemCount() {
return faqList1 == null ? 0 : faqList1.size();
}
class FaqViewHolder extends RecyclerView.ViewHolder {
private RelativeLayout faqItemView;
private RelativeLayout extendedView;
private TextView questionTv, Phone;
private TextView answerTextView, pgstatus, pgAddress;
private LinearLayout ll_top;
private LinearLayout ll_layout1;
private ImageView arrowImgView;
private int holderPosition;
public FaqViewHolder(View itemView) {
super(itemView);
Phone = (TextView) itemView.findViewById(R.id.pgPhoneNo1);
questionTv = (TextView) itemView.findViewById(R.id.pgOwner);
answerTextView = (TextView) itemView.findViewById(R.id.pgPhoneNo);
pgstatus = (TextView) itemView.findViewById(R.id.pgstatus);
pgAddress = (TextView) itemView.findViewById(R.id.pgAddress);
ll_top = (LinearLayout) itemView.findViewById(R.id.ll_top);
ll_layout1 = (LinearLayout) itemView.findViewById(R.id.ll_layout1);
}
}
public void showFilter() {
View popupView = LayoutInflater.from(mContext).inflate(R.layout.pglist_popup, null);
popupWindow = new PopupWindow(popupView, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
final TextView tv_phone = (TextView) popupView.findViewById(R.id.tv_phone);
final LinearLayout ll_layout = (LinearLayout) popupView.findViewById(R.id.ll_layout);
final LinearLayout ll_top = (LinearLayout) popupView.findViewById(R.id.ll_top);
TextView tv_address = (TextView) popupView.findViewById(R.id.tv_address);
final TextView btn_ok = (TextView) popupView.findViewById(R.id.btn_ok);
// popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setOutsideTouchable(false);
popupWindow.setFocusable(false);
tv_phone.setText(ci.getPhone());
tv_address.setText(ci.getAddress());
tv_phone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + tv_phone.getText()));
mContext.startActivity(intent);
}
});
btn_ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.dismiss();
popupWindow = null;
}
});
popupWindow.showAsDropDown(popupView, 0, 0);
}
}
これは私のPgListクラスである: -
public class PgList extends Fragment implements WebServiceListener {
private String responseCodeCameFromServer = "null";
private String responseCameFromServer, responseMessageCameFromServer;
private RecyclerView rvFaqs;
private List<Faq> faqList = new ArrayList<>();
private List<NameValuePair> basicNameValuePair;
private GeneralUtilities generalUtilities;
private SharedPreferencesUtilities sharedPreferencesUtilities;
PgListAdapter pgAdapter;
private View rootView;
private TextView empty_view;
ProgressDialog br;
private PgList pgList;
List<String> typelist = new ArrayList<String>();
List<String> citylist = new ArrayList<String>();
List<CityAreaDetails> temp = new ArrayList<>();
Spinner type;
WebServiceHandler webServiceHandler;
public PgList() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (rootView == null) {
rootView = inflater.inflate(R.layout.pglist, container, false);
generalUtilities = new GeneralUtilities(getActivity());
sharedPreferencesUtilities = new SharedPreferencesUtilities(getActivity());
br = new ProgressDialog(getContext());
br.setTitle("Loading...");
br.setCancelable(false);
empty_view = (TextView) rootView.findViewById(R.id.tv_empty_view);
empty_view.setText("Sorry for the Inconvience! We will update the list very soon for this Area. ");
getActivity().setTitle("PG/Room List");
typelist.add("Boys");
typelist.add("Girls");
citylist.clear();
temp.clear();
rvFaqs = (RecyclerView) rootView.findViewById(R.id.overviewRv);
rvFaqs.setHasFixedSize(true);
rvFaqs.addItemDecoration(new SpacesItemDecoration(20, 20, 12));
rvFaqs.setLayoutManager(new LinearLayoutManager(getActivity()));
rvFaqs.setAdapter(new PgListAdapter(getActivity(), faqList));
webServiceHandler = new WebServiceHandler(getActivity());
webServiceHandler.webServiceListener = PgList.this;
HashMap<String, String> formData = new HashMap<>();
formData.put("Type", "Boys");
formData.put("CityAreaDetailsID", "1");
if (br != null) {
br.show();
}
//Checking internet connectivity and then requesting to the server
Log.e("", "Data :" + formData);
if (generalUtilities.isConnected()) {
webServiceHandler.requestToServer((getResources().getString(R.string.api_end_point)) + "CityDetails",
WebService.ORDER, formData, true);
} else {
if (br != null) {
br.dismiss();
}
generalUtilities.showAlertDialog("Error", getResources().getString(R.string.internet_error), "OK");
}
}
return rootView;
}
私はalertdialogueボックスの[OK]ボタンをクリックしたときに私の問題は、それがalertdialogueを却下ですボックス。 OKボタン(ポジティブボタン)をクリックせずに戻るボタンを押すと、バックボタンに表示されているアクティビティにアラートダイアログボックスが表示されます。
私も同じ問題を抱えています。あなたは解決策を見つけることができますか? –