JakeWharton / ViewPagerIndicator

Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.
http://viewpagerindicator.com
10.14k stars 4.01k forks source link

Updating TextView Font-Size instanty #221

Open alexmen opened 11 years ago

alexmen commented 11 years ago

I have a TextView in all page inside ViewPagerIndicator. When I try to change the textview font size in all page, it doesn't updated the current page because problably ViewPager caches the recent views. So when I navigate to further pages, I can see the changes. How can I make the current page show the changes.

Anybody help me?

danielyip commented 11 years ago

u can try to send a boardcast to change it

alexmen commented 11 years ago

in OnCreate, I do this:


   protected override void OnCreate (Bundle bundle)
   {
    mAdapter = new NoticiaItemAdapter(SupportFragmentManager,mListItems);
    mPager = FindViewById<ViewPager> (Resource.Id.paginador);
    mPager.Adapter=mAdapter;

        mIndicator = FindViewById<CirclePageIndicator> (Resource.Id.indicador);
    mIndicator.SetViewPager (mPager, ItemSelected);
    mIndicator.SetCurrentItem(ItemSelected);

    mIndicator.SetSnap(true);
    mIndicator.SetOnPageChangeListener (this);

    }

In OnCreateOptionsMenu, I put a SubMenu with one item to modify the font size, when you select this subMenu open an alertDialog.Builder with 3 different font size.

If you select an option that run this function

  private void ListClicked (object sender, DialogClickEventArgs e)
  {
       int intFontSize =0;

       TextView TextoNoticia = (TextView)FindViewById(Resource.Id.DescripcionNoticia);

    switch (e.Which) {
        case 0:
        //Pequeño
        intFontSize = Android.Resource.Style.TextAppearanceSmall;
        TextoNoticia.SetTextAppearance(this,Android.Resource.Style.TextAppearanceSmall);
        break;

                case 1:
        //Mediano
        intFontSize = Android.Resource.Style.TextAppearanceMedium;
        TextoNoticia.SetTextAppearance(this,Android.Resource.Style.TextAppearanceMedium);
        break;

               case 2:
        //Grande
        intFontSize = Android.Resource.Style.TextAppearanceLarge;
        TextoNoticia.SetTextAppearance(this,Android.Resource.Style.TextAppearanceLarge);
        break;
    }

    PutPreferenceToPhone("TextAppearence_Noticia_Text", Convert.ToString(intFontSize));

    mPager.RefreshDrawableState();
    mAdapter.NotifyDataSetChanged();

}