How to disable click listener on image view android

Usman Khan picture Usman Khan · Nov 29, 2014 · Viewed 41.1k times · Source

I am working on android application in which i am making click listener on image view. I just want to disable image listener, for example i have a edit button , without clicking edit button image view listener should be disabled.

image = (ImageView) findViewById(R.id.image);

editText.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (clickCount == 0) {
                    Toast.makeText(getApplicationContext(), "Enabled",
                            Toast.LENGTH_SHORT).show();
                    fName.setEnabled(true);
                    lName.setEnabled(true);
                    mailText.setEnabled(true);
                    mobileText.setEnabled(true);
                    mCond.setEnabled(true);
                    mNotes.setEnabled(true);
                    medication.setEnabled(true);
                    alReact.setEnabled(true);
                    dofo.setEnabled(true);
                    image.setEnabled(true);
                    editText.setText("Done");
                    clickCount = 1;

                }

                else if (clickCount == 1) {
                    Toast.makeText(getApplicationContext(), "Done",
                            Toast.LENGTH_SHORT).show();
                    fName.setEnabled(false);
                    lName.setEnabled(false);
                    mailText.setEnabled(false);
                    mobileText.setEnabled(false);
                    meond.setEnabled(false);
                    mNotes.setEnabled(false);
                    meation.setEnabled(false);
                    alReact.setEnabled(false);
                    doInfo.setEnabled(false);
                    image.setEnabled(false);
                    editText.setText("Edit");
                    updatingUser();
                    clickCount = 0;
                }
            }
        });

Answer

Prashant Jajal picture Prashant Jajal · Nov 29, 2014

just add it in onCreate Method

image.setEnabled(false);