Android GridView Button Click Handler

前端 未结 4 1524
名媛妹妹
名媛妹妹 2021-01-05 14:17

I have an Android GridView with an ImageView, TextView and two Button\'s. The Grid is appearing fine but I am finding it

4条回答
  •  灰色年华
    2021-01-05 14:46

    You must use onItemClickListener

     gridview.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView parent, View v, int position, 
                    long row) {
     }
    

    Position should tell you about element clicked. But I think gridview have problems handle objects with clicklisteners (like buttons). Maybe would better changes gridview for other container. If you needs gridview you can use setOnTouchListener for catch position in screen and create a manual onitemclicklistener.

提交回复
热议问题