在我的应用程序中,我使用的是 ListView。在运行期间,我必须更改列表的标题。我试图在下面的代码中做到这一点 -
if (mGroupMembersList != null) {
mGroupMembersList = null;
MTListView tempListView = (MTListView) this.findViewById(R.id.groupMembersList);
tempListView.addHeaderView(getHeaderView(headerTitle));
tempListView.setAdapter(groupMembersAdapter);
mGroupMembersList = tempListView;
}
但是当它到达
tempListView.addHeaderView(getHeaderView(headerTitle));
它抛出
java.lang.IllegalStateException: Cannot add header view to list -- setAdapter has already been called.
如何修复?