0
我在我的操作栏中有一个片段,如果用户单击片段按钮,页面应该自动更新/刷新,如果其中有任何内容。我面临的问题是,片段不会自动更新第一次,而是在第二次按下时更新和刷新。片段不会自动更新点击
这是流量:
选择片段1 - >不更新/刷新 - >返回并从操作栏中选择其他片段2 - >再次选择片段1 - >更新片段1的UI 。
我在异步任务的onPostExecute中从MainActivity调用片段1。
MainActivity,
private final FragmentOne f1 = new FragmentOne();
@Override
protected void onPostExecute(Object o) {
super.onPostExecute(o);
f1.updateUI();
}
我有这样一段代码在我的片段类。
// Updates the fragment-1 UI
public void updateUI() {
if (isAdded()) {
String currentDatabaseName = null;
hideAllTables();
hideWarningLabelsAndHeaders();
progressBarIndicator.setVisibility(View.VISIBLE);
if (null != getUserIdentifier()) {
currentDatabaseName = Utils.buildUserDataFromFli(getUserIdentifier());
}
if (null != currentDatabaseName) {
shopData = new ShopDao(ShopApplication.getLoggedInUser(), Utils.getDatabaseIndexMap());
transcationData = new TranscationDao(ShopApplication.getLoggedInUser(), Utils.getDatabaseIndexMap());
}
configureUserDependentFetchers(getUserIdentifier());
}
}
,你叫asyntask? – sasikumar
第一次调用是否更新了'isAdded'布尔值? –
添加片段时检查布尔值是否正确 – sasikumar