有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java不需要的ListView项目选择

我有一个ListView的方法setOnItemLongClickListener。每当我选择列表项时,ListView中的一些列表项会自动被选中。这是我的密码

listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                String present =listView.getItemAtPosition(position).toString();
                presentStudent.add(present);
            parent.getChildAt(position).setBackgroundColor(getResources().getColor(R.color.colorPrimary));
            return true;
        }
    });
}

共 (0) 个答案