Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GridView onItemClickListener never gets invoked

I have a GridView with custom View in it, which is a Button and a TextView. I defined the setOnItemClickListener but it looks like it never invoked, please see peaces of code below.

gridview = (GridView) findViewById(R.id.main_gridview);
gridview.setAdapter(new GridAdapter(this));

gridview.setOnItemClickListener(new OnItemClickListener() {

    @Override
    public void onItemClick(AdapterView<?> parent, View view, 
            int position, long id) {
        Toast.makeText(getApplicationContext(), "gadsfadsf", 
            Toast.LENGTH_SHORT).show();
        Log.d("Main", "onItemClick");
    }
});
like image 419
Eugene Avatar asked May 12 '11 18:05

Eugene


1 Answers

The marked answer is kind of a hack. Instead of setting an onclicklistener to the button just ensure, that the ButtonView and the TextView has the following property:

android:clickable="false"
like image 191
AZ13 Avatar answered Oct 04 '22 03:10

AZ13