我有一个列表,我正在传递一个数组 然后在html函数的回调中,我将输入的数据更新到列表中 使用
.set
问题是,如果我执行.set,一旦没有任何反应,我会看到一个空白列表,我甚至看不到行,因为我初始化它们。 但是在我之后再次设置。我看到了列表,我希望它如何更新
有时在第二集之后我仍然会看到一个白名单。
为什么这种奇怪的行为?我做错了什么?
列表定义:
aligmentManagerClass = ((appContext) getApplication()).getAligmentManagerVar();
aligmentManagerClass.initlizeBestPositionScreen(bestPositionCallback); // notifies the manager that we initlized best Position Screen
final BestPositionListAdapter adapter = new BestPositionListAdapter(this, arrayOfBaseStations); // Create the adapter to convert the array to views
mainListView = (ListView) findViewById(R.id.bestPosition_layout_list); // Attach the adapter to a ListView
mainListView.setAdapter(adapter);
mainListView.setOnItemClickListener(this); // sets an item click on the list
这是实际的列表回调:
//CALLBACL for When wifi Is turned on or Not
bestPositionCallbackInterface bestPositionCallback = new bestPositionCallbackInterface() {
@Override
public void bestPositionCallbck (int i, BestPositionListModel modelData, int listSize) {
//IMPLEMENT THE SERVICE CODE HERE >
if (listDataGenerated == false) {
for (int j = 0; j < listSize; j++) { // initlizes the aligment list Array List
arrayOfBaseStations.add(new BestPositionListModel("1", "1", "1", "1", "1", "1", "1", "1", "1", "1"));
}
listDataGenerated = true;
}
arrayOfBaseStations.set(i, new BestPositionListModel( // We need to set everything first to aliminate an anoying android bug
String.valueOf (0),
String.valueOf (1),
String.valueOf (2),
String.valueOf (3),
String.valueOf (4),
String.valueOf (5),
String.valueOf (6),
String.valueOf (7),
String.valueOf (8),
String.valueOf (9)));
arrayOfBaseStations.set(i, new BestPositionListModel( // this is the real value were adding
String.valueOf (modelData.channelSectorType),
String.valueOf (modelData.channelAngle),
String.valueOf (modelData.channelElvation),
String.valueOf (modelData.channelAntBeamWidth),
String.valueOf (modelData.channelShort),
String.valueOf (modelData.CBW),
String.valueOf (modelData.bestRSS),
String.valueOf (modelData.sectorID),
String.valueOf (modelData.avilableResurces),
String.valueOf (modelData.bestEffortHSU)));
}
};
答案 0 :(得分:1)
将数据添加到列表后,您应该使用adapter.notifydatasetchanged()
。你试过吗?