Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable click listener on image view android

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;
                }
            }
        });
like image 891
Usman Khan Avatar asked Nov 29 '14 07:11

Usman Khan


2 Answers

just add it in onCreate Method

image.setEnabled(false);

like image 122
Prashant Jajal Avatar answered Sep 18 '22 12:09

Prashant Jajal


Use this line into your XML:

android:clickable="false"
like image 33
Nazmus Saadat Avatar answered Sep 17 '22 12:09

Nazmus Saadat