0

I have a PopUpMenu list, when i click on the menu i should refresh my Ui and display the updated data from database.

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

my issue is when first time i click the menu ,the page refreshing but not data, again if i click the second time its refreshing and getting data.. I'am struck any help is appreciated

Saro Taşciyan
  • 5,210
  • 5
  • 31
  • 50
teekib
  • 2,821
  • 10
  • 39
  • 75
  • refer this link http://stackoverflow.com/questions/5991968/how-to-force-an-entire-layout-view-refresh – Priya Feb 06 '13 at 12:35

1 Answers1

0

Use yourView.invalidate() to refresh your view. where yourView is the view which you want to refresh

AbdulHannan
  • 358
  • 1
  • 15