我有一个PopUpMenu
列表,当我点击菜单时,我应该刷新我的用户界面并显示数据库中的更新的数据
public void DoAction(View v, Activity activity, final AlertDialog alert)
{
Context myContext = v.getContext();
PopUpMenu popUpMenu = (PopUpMenu) v.getTag();
String result = popUpMenu.getMenuName();
if (result != null && result.equalsIgnoreCase(myContext.getResources().getString(R.string.showdist)))
{
showPopupSearchPref(myContext, activity);
}
else if (result != null && result.equalsIgnoreCase(myContext.getResources().getString(R.string.syncnow)))
{
Synchronization sync = new Synchronization(v.getContext());
sync.initiatePushSync(Calendar.SECOND, 0);
sync.initiatePullSync(Calendar.SECOND, 0);
Constants.Data = ((myPreferences) myContext.getApplicationContext()).getAllAttractions(true,Constants.field, Constants.order);
activity.finish();
}
}
public void initiatePullSync(int calenderType, int time)
{
Calendar newTime = Calendar.getInstance();
newTime.add(calenderType, time);
Log.d(TAG, "Syncronisation Device - Cloud " + newTime.getTime());
if(Constants.syncPull == null)
{
Constants.syncPull = new Intent(context, PullFavourite.class);
Log.d(TAG, "Syncronisation Device - Cloud Creating New Intent");
}
PendingIntent sender = PendingIntent.getBroadcast(context, Constants.syncPullFavPlaceId, Constants.syncPull, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager am = (AlarmManager)context.getSystemService(context.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, newTime.getTime().getTime(), sender);
Log.d(TAG, "Syncronisation Device - Cloud Reschedule after " + time + calenderType);
}
我的问题是第一次我点击菜单,页面刷新但不是数据,再次点击第二次 刷新并获取数据 ..我很感激任何帮助
答案 0 :(得分:0)
使用yourView.invalidate()
刷新您的观点。其中yourView
是您要刷新的视图