我使用我的 ArrayAdapter 扩展的 getView 方法。我更改 CheckBox 但 ListView 不刷新
我的来源
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Planet to display
UrlItem urlItem = (UrlItem) this.getItem(position);
ViewHolder viewHolder = null;
if (convertView == null) {
convertView = inflater.inflate(R.layout.database_table_item, null);
viewHolder = new ViewHolder();
viewHolder.checkbox = (CheckBox) convertView
.findViewById(R.id.checkBox1);
viewHolder.checkbox
.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
int getPosition = (Integer) buttonView.getTag();
DatabaseTable.setPosition(getPosition);
for (int i = 0; i < UrlItems.size(); i ++ ) {
UrlItems.get(i).setUse(false);
}
UrlItems.get(getPosition).setUse(isChecked);
}
});
更改后如何刷新列表?
在清单集中供您参考
<activity
android:name=".DatabaseTable"
android:label="database_table" android:windowSoftInputMode="adjustPan" >
使用“selectAll”按钮查看升级链接我有完全相同的想法,但没有按钮 selectAll