0

我有一个PopUpMenu列表,当我单击菜单时,我应该刷新我的 Ui 并显示来自数据库的更新数据。

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);
}

我的问题是当我第一次单击菜单时,页面刷新但没有数据,如果我第二次单击它刷新并获取数据.. 我很震惊任何帮助表示赞赏

4

1 回答 1

0

用于yourView.invalidate()刷新您的视图。yourView您要刷新的视图在哪里

于 2013-02-06T12:23:19.523 回答