这里我的ListView
连续几个小部件。
我需要获得小部件的正确位置并在适配器内管理它们的可见性。目前,它对last item
的{{1}}可见。
我在这里也使用ListView
和getTag()
,但它没有取得成功。
setTag()
答案 0 :(得分:3)
对于此问题,您必须使用arrayList
并在其中设置一个位置为
//Define arraylist globally
private List<Boolean> requestionVisibleState;
//set a default value in constructor of adapter
this.requestionVisibleState = new ArrayList<>(Arrays.asList(new Boolean[getCount()]));
Collections.fill(this.requestionVisibleState, false);
//In getView after completing if else statement
if (requestionVisibleState.get(position)) {
holder.submitAnswerBtn.setVisibility(View.VISIBLE);
holder.requestion_layout.setVisibility(View.VISIBLE);
}
//And in `onClick` of your ClicableSpan
if (requestionVisibleState.get(position)) {
requestionVisibleState.set(position, false);
} else {
requestionVisibleState.set(position, true);
}
notifyDataSetChanged();
我希望它能为你效劳。