Skip to content Skip to sidebar Skip to footer

How To Show Element By Timer?

I have a problem. I have an Activity with ViewPager which have some Fragments. In my first Fragment I have some elements. Lets say an ImageView, TextView. How to make them visible

Solution 1:

I would not use a timer. It would either fire too early, or too late during which your UI looks bad. Use the pager's events to know when to update your UI. For example, you can probably use OnPageChangedListener:

    pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
       @Override
       public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

       }

       @Override
       public void onPageSelected(int position) {
            // Now displaying page at position
       }

       @Override
       public void onPageScrollStateChanged(int state) {

       }
   };

Post a Comment for "How To Show Element By Timer?"