如何从列表视图中选择项目?我正确地得到了所选的值

时间:2017-08-31 12:29:40

标签: android listview

我从所选项目中获取位置,但在列表视图中单击我的项目时不显示。我在下面附上了代码并附上了截图:

      listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            list_pos=position;

            for (int i = 0; i < itemlist.size(); i++) {
                if (i == position) {
                    System.out.println("**********venki*******hai*");
                    itemlist.get(i).setSelect_show("selected");
                } else {
                    System.out.println("**********venki*******notslected*");
                    itemlist.get(i).setSelect_show("not selected");
                }
            }

             if (itemlist.get(position).getRatingId().equalsIgnoreCase("13")){
                // showreviewPopup();
                 Et_comment.setVisibility(View.VISIBLE);

             }else{
                 Et_comment.setVisibility(View.GONE);
             }


        }
    });
}

这是我的适配器类:

    if(data.get(position).getSelect_show().equalsIgnoreCase("selected")){



        holder.Im_sel_option.setImageResource(R.drawable.card_selected);

    }else {

        holder.Im_sel_option.setImageResource(R.drawable.card_unselect);

    }

enter image description here

0 个答案:

没有答案