Ad

AlertDialog Not Closing When Inforamtion Is Saved

- 1 answer

My previous question is solved, but now I have another one.

My If condition not working properly

Scenario: 1. If user has not filled up his Name, then Alert Dialog is displayed 2. If user has filled up his Name, then Alert Dialog should NOT displayed

In my case, I will get Alert Dialog in any case, it does not care if Name is filled or not.

ArtistProfileView.Java

public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.activity_artist_profile_view, container, false);
        prefrence = SharedPrefrence.getInstance(getActivity());
        userDTO = prefrence.getParentUser(Consts.USER_DTO);
        paramsRate.put(Consts.ARTIST_ID, userDTO.getUser_id());
        parms.put(Consts.ARTIST_ID, userDTO.getUser_id());
        parms.put(Consts.USER_ID, userDTO.getUser_id());
        baseActivity.headerNameTV.setText(getResources().getString(R.string.my_profile));
        if(artistDetailsDTO.getName().isEmpty()) {
            new AlertDialog.Builder(getActivity())
                    .setView(getLayoutInflater().inflate(R.layout.test5, null))
                    .setPositiveButton(R.string.okaypopup22,
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int id) {
                                    my_tag = 1;
                                    dialogPersonalProfile();
                                }
                            })
                    .show();
        }
        setUiAction(view);
        return view;
}

In the same Class, method which calls profile editing

@Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ivEditPersonal:
                my_tag = 1;
                dialogPersonalProfile();
                break;
            case R.id.ivEditAbout:
                my_tag = 2;
                dialogAbout();
                break;
            case R.id.ivEditQualification:
                dialogQualification();
                break;
            case R.id.ivEditSkils:
                my_tag = 3;
                dialogSkills();
                break;
            case R.id.ivEditProduct:
                dialogProduct();
                break;
            case R.id.ivEditGallery:
                dialogGallery();
                break;


        }
    }
Ad

Answer

At first I misunderstood your question, so I have edited it.

I guess you should try adding equals() method in if condition

if(artistDetailsDTO.getName().toString.equals(""))
Ad
source: stackoverflow.com
Ad