我希望可见,然后单击图像而不是完整的行。我使用了持有人模式

时间:2014-01-22 10:48:29

标签: android android-custom-view

public void onItemClick(AdapterView<?> parent,
                    View clickedView, int position, long arg3) {
                //TODO Auto-generated method stub

                System.err.println("rowClickedEvent");
                position = position - 1;
if (clickedRowID != -1 && clickedRowID != position) {

                    View clickedViewToClose = actualListView
                            .getChildAt(clickedRowID + 1);
                    if (clickedViewToClose != null) {
                        RelativeLayout roww = (RelativeLayout) clickedViewToClose
                                .findViewById(R.id.add_row);
                        roww.setVisibility(View.GONE);

                    } else {
                        System.err.println("clickedViewToClose null");
                    }
                }
                if ((clickedRowID != position)) {



                        }
                    });


                    clickedRowID = position;


                } else if (clickedRowID == position) {


                    RelativeLayout roww = (RelativeLayout) clickedView
                            .findViewById(R.id.add_row);
                    roww.setVisibility(View.GONE);
                    clickedRowID = -1;
                    dataAdapter.notifyDataSetChanged();
                }

}

2 个答案:

答案 0 :(得分:0)

在getView()方法的适配器中添加holder.imageView.setOnClickListener()

答案 1 :(得分:0)

holder.imageView.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                yourview.setVisibility(View.GONE);//do ur code here

            }
        });