user2702700
user2702700

Reputation: 639

disable gridview item onClick and enable only on child view

Hi I have a gridview with imageview and textview in each gridview item. I want to disable onclick of grid view item and enable it only for imageview. Is there any way this can be achieved. I have have lot of space between each grid view item and if i have onclick enabled for each gridview item then ontimeclick listener will be called even if i click on empty spaces to avoid this i am planing to have onclick only for imageview.... pls suggest how this can be done...

Upvotes: 1

Views: 6351

Answers (2)

Gopal Reddy
Gopal Reddy

Reputation: 36

 if(count==1)
    {
        button.setEnabled(false);
    }
      button.setOnClickListener(new View.OnClickListener() {



          @Override
          public void onClick(View view) {

              switch (position) {
                  case 0:
                      count++;
                  Intent intent = new Intent(context, ssss.class);
                  Bundle bundle = new Bundle();
                  intent.putExtras(bundle);
                  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                  context.startActivity(intent);
                break;
                  case 1:
                     button.setEnabled(true);
                      break;

                  case 2:
                      button.setEnabled(true);
                      break;


              }
          }
      });

Use This in Level Adapter

Upvotes: 0

Kavin
Kavin

Reputation: 544

You can give android:clickable="false" for gridview in your xml.

And, you can write onClick for imageview inside custom adapter where you have populated your gridview.

Also try,

android:focusable="false"
android:focusableInTouchMode="false"

for your gridview in xml.

Upvotes: 2

Related Questions