Example usage for android.widget TextView animate

List of usage examples for android.widget TextView animate

Introduction

In this page you can find the example usage for android.widget TextView animate.

Prototype

public ViewPropertyAnimator animate() 

Source Link

Document

This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.

Usage

From source file:Main.java

public static void animateTextViewTextChange(final TextView textView, final int duration,
        final String newText) {
    textView.animate().alpha(0f).setDuration(duration).setListener(new Animator.AnimatorListener() {
        @Override//from ww w. j av a 2  s  .c om
        public void onAnimationEnd(Animator animation) {
            textView.setText(newText);
            textView.animate().alpha(1f).setDuration(duration).start();
        }

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    }).start();
}

From source file:com.waz.zclient.pages.main.profile.preferences.dialogs.VerifyPhoneNumberPreferenceFragment.java

@Nullable
@Override// w  w  w  . java2s.  c o  m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final String number = PhoneNumberUtils.formatNumber(getArguments().getString(ARG_PHONE, ""));
    final View view = inflater.inflate(R.layout.fragment_preference_phone_number_verification, container,
            false);

    final TextInputLayout verificationCodeInputLayout = ViewUtils.getView(view, R.id.til__verification_code);
    verificationCodeInputLayout.setErrorEnabled(true);
    final View backButton = ViewUtils.getView(view, R.id.tv__back_button);
    backButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    final View okButton = ViewUtils.getView(view, R.id.tv__ok_button);
    okButton.setEnabled(false);
    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final String code = getVerificationCode();
            getStoreFactory().getProfileStore().submitCode(number, code,
                    new ZMessagingApi.PhoneNumberVerificationListener() {
                        @Override
                        public void onVerified(KindOfVerification kindOfVerification) {
                            dismiss();
                        }

                        @Override
                        public void onVerificationFailed(KindOfVerification kindOfVerification, int errorCode,
                                String message, String label) {
                            if (AppEntryError.PHONE_INVALID_REGISTRATION_CODE.correspondsTo(errorCode, label)) {
                                verificationCodeInputLayout.setError(getString(
                                        AppEntryError.PHONE_INVALID_REGISTRATION_CODE.headerResource));
                            } else {
                                verificationCodeInputLayout.setError(
                                        getString(AppEntryError.PHONE_REGISTER_GENERIC_ERROR.headerResource));
                            }
                        }
                    });
        }
    });
    final TextView changeNumberButton = ViewUtils.getView(view, R.id.tv__change_number_button);
    changeNumberButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (getContainer() == null) {
                return;
            }
            dismiss();
            getContainer().changePhoneNumber(number);
        }
    });
    final TextView resendButton = ViewUtils.getView(view, R.id.tv__resend_button);
    resendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            resendButton.animate().alpha(0f).start();
            getStoreFactory().getProfileStore().resendPhoneVerificationCode(number,
                    new ZMessagingApi.PhoneConfirmationCodeRequestListener() {

                        @Override
                        public void onConfirmationCodeSent(KindOfAccess kindOfAccess) {
                            resendButton.animate().alpha(1f).start();
                        }

                        @Override
                        public void onPasswordExists(KindOfAccess kindOfAccess) {

                        }

                        @Override
                        public void onConfirmationCodeSendingFailed(KindOfAccess kindOfAccess, int code,
                                String message, String label) {
                            resendButton.animate().alpha(1f).start();
                            AppEntryUtil.showErrorDialog(getActivity(),
                                    AppEntryError.PHONE_REGISTER_GENERIC_ERROR, null);
                        }
                    });
        }
    });
    final TextView verificationDescription = ViewUtils.getView(view, R.id.tv__verification_description);
    verificationDescription
            .setText(getString(R.string.pref__account_action__phone_verification__description, number));

    final EditText firstNumberEditText = ViewUtils.getView(view, R.id.et__verification_code__1);
    final EditText secondNumberEditText = ViewUtils.getView(view, R.id.et__verification_code__2);
    final EditText thirdNumberEditText = ViewUtils.getView(view, R.id.et__verification_code__3);
    final EditText fourthNumberEditText = ViewUtils.getView(view, R.id.et__verification_code__4);
    final EditText fifthNumberEditText = ViewUtils.getView(view, R.id.et__verification_code__5);
    final EditText sixthNumberEditText = ViewUtils.getView(view, R.id.et__verification_code__6);

    textBoxes = new LinkedList<>(Arrays.asList(firstNumberEditText, secondNumberEditText, thirdNumberEditText,
            fourthNumberEditText, fifthNumberEditText, sixthNumberEditText));
    for (int i = 0; i < textBoxes.size(); i++) {
        final EditText textBox = textBoxes.get(i);
        final int finalI = i;
        textBox.setTypeface(TypefaceUtils.getTypeface(getString(R.string.wire__typeface__bold)));
        textBox.addTextChangedListener(new OnTextChangedListener() {
            @Override
            public void afterTextChanged(Editable s) {
                verificationCodeInputLayout.setError(null);
                final String val = textBox.getText().toString().trim();
                final char c;
                if (TextUtils.isEmpty(val)) {
                    c = ' ';
                } else {
                    c = val.charAt(0);
                }
                verificationCode[finalI] = c;
                final boolean wasDelete = c == ' ';
                if (!jumpToNextEmptyTextBox(wasDelete)) {
                    okButton.setEnabled(true);
                    if (finalI == textBoxes.size()) {
                        okButton.requestFocus();
                    }
                } else {
                    okButton.setEnabled(false);
                }
            }
        });
    }

    return view;
}

From source file:com.hannesdorfmann.home.HomeActivity.java

private void animateToolbar() {
    // this is gross but toolbar doesn't expose it's children to animate them :(
    View t = toolbar.getChildAt(0);
    if (t != null && t instanceof TextView) {
        TextView title = (TextView) t;

        // fade in and space out the title.  Animating the letterSpacing performs horribly so
        // fake it by setting the desired letterSpacing then animating the scaleX \_()_/
        title.setAlpha(0f);/* w ww  .  ja  va2 s.c  o  m*/
        title.setScaleX(0.8f);

        title.animate().alpha(1f).scaleX(1f).setStartDelay(300).setDuration(900).setInterpolator(
                AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in));
    }
    View amv = toolbar.getChildAt(1);
    if (amv != null & amv instanceof ActionMenuView) {
        ActionMenuView actions = (ActionMenuView) amv;
        popAnim(actions.getChildAt(0), 500, 200); // filter
        popAnim(actions.getChildAt(1), 700, 200); // overflow
    }
}

From source file:com.hybris.mobile.app.commerce.activity.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem item = menu.findItem(R.id.b2b_icon_cart);

    if (item != null) {
        final TextView totalItems = (TextView) item.getActionView().findViewById(R.id.cart_total_unit_text);

        totalItems.setVisibility(View.VISIBLE);
        totalItems.setText(SessionHelper.getCartTotalUnitCount() + "");

        // Updating cart item numbers OR resetting the view with the item numbers
        if (SessionHelper.getCartTotalUnitCount() != SessionHelper.getCartTotalUnitCountPrevious()) {

            // Animate the view by a scaleIn / scaleOut
            totalItems.animate().scaleYBy(UIUtils.CART_ITEM_ACTION_BAR_ICON_SCALE_FACTOR)
                    .setDuration(UIUtils.CART_ITEM_ACTION_BAR_ICON_SCALE_DURATION).setListener(null);
            totalItems.animate().scaleXBy(UIUtils.CART_ITEM_ACTION_BAR_ICON_SCALE_FACTOR)
                    .setDuration(UIUtils.CART_ITEM_ACTION_BAR_ICON_SCALE_DURATION)
                    .setListener(new AnimatorListener() {

                        @Override
                        public void onAnimationStart(Animator animation) {
                        }/*from  w  ww  . j a va  2 s  .  co m*/

                        @Override
                        public void onAnimationRepeat(Animator animation) {
                        }

                        @Override
                        public void onAnimationEnd(Animator animation) {

                            // We scale out at the original size
                            if (SessionHelper.getCartTotalUnitCount() > 0) {
                                SessionHelper.syncCartTotalUnitCountPrevious();

                                totalItems.animate().scaleXBy(-UIUtils.CART_ITEM_ACTION_BAR_ICON_SCALE_FACTOR)
                                        .setDuration(UIUtils.CART_ITEM_ACTION_BAR_ICON_SCALE_DURATION)
                                        .setListener(null);
                                totalItems.animate().scaleYBy(-UIUtils.CART_ITEM_ACTION_BAR_ICON_SCALE_FACTOR)
                                        .setDuration(UIUtils.CART_ITEM_ACTION_BAR_ICON_SCALE_DURATION)
                                        .setListener(null);
                            }
                            // Or if we just empty the cart, we scale out completely and hide the view
                            else if (SessionHelper.getCartTotalUnitCountPrevious() != 0) {
                                SessionHelper.resetCartTotalUnitCountPrevious();

                                totalItems.animate().scaleXBy(-1.5f)
                                        .setDuration(UIUtils.CART_ITEM_ACTION_BAR_ICON_SCALE_DURATION)
                                        .setListener(null);
                                totalItems.animate().scaleYBy(-1.5f)
                                        .setDuration(UIUtils.CART_ITEM_ACTION_BAR_ICON_SCALE_DURATION)
                                        .setListener(new AnimatorListener() {

                                            @Override
                                            public void onAnimationStart(Animator animation) {
                                            }

                                            @Override
                                            public void onAnimationRepeat(Animator animation) {
                                            }

                                            @Override
                                            public void onAnimationEnd(Animator animation) {
                                                totalItems.setVisibility(View.GONE);
                                            }

                                            @Override
                                            public void onAnimationCancel(Animator animation) {
                                            }
                                        });
                            }
                        }

                        @Override
                        public void onAnimationCancel(Animator animation) {
                        }
                    });
        } else if (SessionHelper.getCartTotalUnitCount() == 0) {
            totalItems.setVisibility(View.GONE);
        }
    }

    return true;
}

From source file:io.plaidapp.ui.HomeActivity.java

private void animateToolbar() {
    // this is gross but toolbar doesn't expose it's children to animate them :(
    View t = toolbar.getChildAt(0);
    if (t != null && t instanceof TextView) {
        TextView title = (TextView) t;

        // fade in and space out the title.  Animating the letterSpacing performs horribly so
        // fake it by setting the desired letterSpacing then animating the scaleX \_()_/
        title.setAlpha(0f);//w w w.  j ava 2 s  . c o  m
        title.setScaleX(0.8f);

        title.animate().alpha(1f).scaleX(1f).setStartDelay(300).setDuration(900)
                .setInterpolator(AnimUtils.getFastOutSlowInInterpolator(this));
    }
}

From source file:com.example.zayankovsky.homework.ui.ImageDetailActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image_detail);
    getWindow().getDecorView().setBackgroundResource(
            PreferenceManager.getDefaultSharedPreferences(this).getString("theme", "light").equals("dark")
                    ? R.color.darkColorTransparent
                    : R.color.lightColorTransparent);

    // Set up activity to go full screen
    getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN);

    // Locate the main ImageView and TextView
    mImageView = (ImageView) findViewById(R.id.imageView);
    final TextView mTextView = (TextView) findViewById(R.id.textView);

    mSectionNumber = getIntent().getIntExtra(SECTION_NUMBER, 0);
    registerForContextMenu(mImageView);/*from  w  w w .j  ava2  s.  c o m*/
    mImageView.setLongClickable(false);

    // Enable some additional newer visibility and ActionBar features
    // to create a more immersive photo viewing experience
    final ActionBar actionBar = getSupportActionBar();

    if (actionBar != null) {
        // Set home as up
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Hide and show the ActionBar and TextView as the visibility changes
        mImageView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int vis) {
                if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
                    actionBar.hide();
                    if (mSectionNumber == 1) {
                        mTextView.animate().translationY(mTextView.getHeight())
                                .setListener(new AnimatorListenerAdapter() {
                                    @Override
                                    public void onAnimationEnd(Animator animation) {
                                        mTextView.setVisibility(View.GONE);
                                    }
                                });
                    }
                } else {
                    actionBar.show();
                    if (mSectionNumber == 1) {
                        mTextView.animate().translationY(0).setListener(new AnimatorListenerAdapter() {
                            @Override
                            public void onAnimationStart(Animator animation) {
                                mTextView.setVisibility(View.VISIBLE);
                            }
                        });
                    }
                }
            }
        });

        // Start low profile mode and hide ActionBar
        mImageView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        actionBar.hide();
    }

    GestureListener.init(this, mImageView);
    ScaleGestureListener.init(mImageView);

    // Use the ImageWorker to load the image into the ImageView
    // (so a single cache can be used over all pages in the ViewPager)
    // based on the extra passed in to this activity
    int position = getIntent().getIntExtra(POSITION, 0);
    switch (mSectionNumber) {
    case 0:
        GalleryWorker.loadImage(position, mImageView);
        break;
    case 1:
        FotkiWorker.loadImage(position, mImageView);
        mTextView.setText(getResources().getString(R.string.detail_text, FotkiWorker.getAuthor(),
                new SimpleDateFormat("d MMMM yyyy", Locale.getDefault()).format(FotkiWorker.getPublished())));
        break;
    case 2:
        ResourcesWorker.loadImage(position, mImageView);
        break;
    }
    setTitle(ImageWorker.getTitle());

    // First we create the GestureListener that will include all our callbacks.
    // Then we create the GestureDetector, which takes that listener as an argument.
    GestureDetector.SimpleOnGestureListener gestureListener = new GestureListener();
    final GestureDetector gd = new GestureDetector(this, gestureListener);

    ScaleGestureDetector.SimpleOnScaleGestureListener scaleGestureListener = new ScaleGestureListener();
    final ScaleGestureDetector sgd = new ScaleGestureDetector(this, scaleGestureListener);

    /* For the view where gestures will occur, we create an onTouchListener that sends
     * all motion events to the gesture detectors.  When the gesture detectors
     * actually detects an event, it will use the callbacks we created in the
     * SimpleOnGestureListener and SimpleOnScaleGestureListener to alert our application.
    */

    findViewById(R.id.frameLayout).setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            gd.onTouchEvent(motionEvent);
            sgd.onTouchEvent(motionEvent);
            return true;
        }
    });
}

From source file:info.bartowski.easteregg.MLand.java

public void start(boolean startPlaying) {
    L("start(startPlaying=%s)", startPlaying ? "true" : "false");
    if (startPlaying && mCountdown <= 0) {
        showSplash();/*w  ww  .j  ava 2 s  .  c o  m*/

        mSplash.findViewById(R.id.play_button).setEnabled(false);

        final View playImage = mSplash.findViewById(R.id.play_button_image);
        final TextView playText = (TextView) mSplash.findViewById(R.id.play_button_text);

        playImage.animate().alpha(0f);
        playText.animate().alpha(1f);

        mCountdown = 3;
        post(new Runnable() {
            @Override
            public void run() {
                if (mCountdown == 0) {
                    startPlaying();
                } else {
                    postDelayed(this, 500);
                }
                playText.setText(String.valueOf(mCountdown));
                mCountdown--;
            }
        });
    }

    for (Player p : mPlayers) {
        p.setVisibility(View.INVISIBLE);
    }

    if (!mAnimating) {
        mAnim.start();
        mAnimating = true;
    }
}

From source file:com.fastbootmobile.encore.app.fragments.ArtistFragment.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void notifyClosing() {
    Utils.animateScale(mFabPlay, true, false);
    final TextView tvArtist = (TextView) mRootView.findViewById(R.id.tvArtist);
    final PagerTabStrip strip = (PagerTabStrip) mRootView.findViewById(R.id.pagerArtistStrip);

    if (!Utils.hasLollipop()) {
        tvArtist.animate().alpha(0.0f).setStartDelay(0).setDuration(ArtistActivity.BACK_DELAY).start();
    }/*from  w  w w .ja v a  2 s  .  c om*/
    strip.animate().alpha(0.0f).setStartDelay(0).translationY(-20).setDuration(ArtistActivity.BACK_DELAY)
            .start();
}

From source file:com.fastbootmobile.encore.app.fragments.ArtistFragment.java

/**
 * {@inheritDoc}/* w ww. j  a  v a2s.c o m*/
 */
@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mHandler = new Handler();

    // Setup the inside fragments
    mArtistTracksFragment = new ArtistTracksFragment();
    mArtistTracksFragment.setParentFragment(this);

    mArtistInfoFragment = new ArtistInfoFragment();
    mArtistInfoFragment.setArguments(mArtist);

    mArtistSimilarFragment = new ArtistSimilarFragment();
    mArtistSimilarFragment.setArguments(mArtist);

    // Inflate the main fragment view
    mRootView = (ParallaxScrollView) inflater.inflate(R.layout.fragment_artist, container, false);

    // Set the hero image and artist from arguments
    mHeroImageView = (ImageView) mRootView.findViewById(R.id.ivHero);
    if (mHeroImage != null) {
        mHeroImageView.setImageBitmap(mHeroImage);

        // The hero image that comes from a transition might be low in quality, so load
        // the higher quality and fade it in
        loadArt(false);
    } else {
        // Display placeholder and try to get the real art
        mHeroImageView.setImageResource(R.drawable.album_placeholder);
        loadArt(true);
    }

    final TextView tvArtist = (TextView) mRootView.findViewById(R.id.tvArtist);
    tvArtist.setBackgroundColor(mBackgroundColor);
    tvArtist.setText(mArtist.getName());

    final PagerTabStrip strip = (PagerTabStrip) mRootView.findViewById(R.id.pagerArtistStrip);
    strip.setDrawFullUnderline(false);
    strip.setAlpha(0.0f);
    strip.setTranslationY(-20);
    strip.animate().alpha(1.0f).setDuration(ANIMATION_DURATION).setStartDelay(500).translationY(0).start();

    if (!Utils.hasLollipop()) {
        tvArtist.setAlpha(0);
        tvArtist.animate().alpha(1).setDuration(ANIMATION_DURATION).setStartDelay(500).start();
    }

    // Setup the subfragments pager
    final WrapContentHeightViewPager pager = (WrapContentHeightViewPager) mRootView
            .findViewById(R.id.pagerArtist);
    pager.setAdapter(new ViewPagerAdapter(getChildFragmentManager()));
    pager.setOffscreenPageLimit(FRAGMENT_COUNT);

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

        @Override
        public void onPageSelected(int i) {
            if (mRootView.getScrollY() > tvArtist.getTop()) {
                mRootView.smoothScrollTo(0, tvArtist.getTop());
            }
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    pager.setMinimumHeight(500);
                    pager.requestLayout();
                }
            });

            boolean hasRosetta = ProviderAggregator.getDefault().getRosettaStonePrefix().size() > 0;

            if (hasRosetta) {
                if (i == FRAGMENT_ID_BIOGRAPHY) {
                    mArtistInfoFragment.notifyActive();
                } else if (i == FRAGMENT_ID_SIMILAR) {
                    mArtistSimilarFragment.notifyActive();
                }
            } else {
                if (i == FRAGMENT_ID_SIMILAR) {
                    // This is actually BIOGRAPHY if rosetta is not available
                    mArtistInfoFragment.notifyActive();
                }
            }
        }

        @Override
        public void onPageScrollStateChanged(int i) {
        }
    });

    mRootView.setOnScrollListener(new ObservableScrollView.ScrollViewListener() {
        @Override
        public void onScroll(ObservableScrollView scrollView, int x, int y, int oldx, int oldy) {
            final ActionBar ab = ((AppActivity) getActivity()).getSupportActionBar();
            if (ab != null) {
                if (y >= tvArtist.getTop()) {
                    ab.hide();
                } else {
                    ab.show();
                }
            }
        }
    });

    // Setup the source logo
    final ImageView ivSource = (ImageView) mRootView.findViewById(R.id.ivSourceLogo);
    mLogoBitmap = PluginsLookup.getDefault().getCachedLogo(getResources(), mArtist);
    ivSource.setImageDrawable(mLogoBitmap);

    // Outline is required for the FAB shadow to be actually oval
    mFabPlay = (FloatingActionButton) mRootView.findViewById(R.id.fabPlay);
    showFab(false, false);

    // Set the FAB animated drawable
    mFabDrawable = new PlayPauseDrawable(getResources(), 1);
    mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY);
    mFabDrawable.setYOffset(6);

    final Song currentTrack = PlaybackProxy.getCurrentTrack();
    if (currentTrack != null && currentTrack.getArtist() != null
            && currentTrack.getArtist().equals(mArtist.getRef())) {
        int state = PlaybackProxy.getState();
        if (state == PlaybackService.STATE_PLAYING) {
            mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE);
        } else if (state == PlaybackService.STATE_PAUSED) {
            mFabShouldResume = true;
        } else if (state == PlaybackService.STATE_BUFFERING) {
            mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY);
            mFabDrawable.setBuffering(true);
            mFabShouldResume = true;
        } else if (state == PlaybackService.STATE_PAUSING) {
            mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE);
            mFabDrawable.setBuffering(true);
            mFabShouldResume = true;
        }
    }

    mFabPlay.setImageDrawable(mFabDrawable);
    mFabPlay.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mFabDrawable.getCurrentShape() == PlayPauseDrawable.SHAPE_PLAY) {
                if (mFabShouldResume) {
                    PlaybackProxy.play();
                } else {
                    mArtistTracksFragment.playRecommendation();
                }
            } else {
                mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE);
                mFabShouldResume = true;
                PlaybackProxy.pause();
            }
        }
    });

    return mRootView;
}

From source file:org.shaastra.helper.SuperAwesomeCardFragment.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override/*ww  w.  jav a 2  s .  c  o  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    //v.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD " + (position + 1));

    if (position == 0) {
        View v1 = inflater.inflate(R.layout.event_info, container, false);
        v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        TextView t1 = (TextView) v1.findViewById(R.id.infotext);
        t1.setText(eintroduction);
        return v1;
    } else if (position == 1)

    {

        String Venue = new String();
        Venue = evenue;

        final String SAC = elatlong;
        //String start=String.valueOf(l.getLatitude())+String.valueOf(l.getLongitude());
        /*
        View v1=inflater.inflate(R.layout.map, container,false);
        v1.setLayoutParams(params);
        WebView wv=(WebView)v1.findViewById(R.id.wv1);
        wv.setWebChromeClient(new WebChromeClient());
        //wv.loadUrl("https://maps.google.com/maps?saddr=13,80&daddr=13,80.02");
        //wv.loadUrl("http://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=false");
        wv.loadUrl("http://maps.google.com/maps?f=d&daddr=51.448,-0.972");
        wv.getSettings().getBuiltInZoomControls();
        */
        View v1 = inflater.inflate(R.layout.map, container, false);
        v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        TextView location = (TextView) v1.findViewById(R.id.locationText);
        Button mapButton = (Button) v1.findViewById(R.id.mapButton);
        if (evenue.equalsIgnoreCase("NONE")) {
            mapButton.setAlpha(0);
        } else {
            mapButton.setAlpha(1);
        }

        location.setText(Venue);
        mapButton.setOnTouchListener(new View.OnTouchListener() {

            @TargetApi(Build.VERSION_CODES.HONEYCOMB)
            @SuppressLint("NewApi")
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub
                if (event.getAction() == MotionEvent.ACTION_DOWN) {

                    v.setAlpha((float) 0.4);
                    v.animate().setInterpolator(new DecelerateInterpolator()).scaleX(0.9f).scaleY(0.9f);

                }
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    v.setAlpha((float) 0.75);
                    v.animate().setInterpolator(new OvershootInterpolator()).scaleX(1f).scaleY(1f);

                    Intent intent = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("http://maps.google.com/maps?f=d&daddr=" + SAC));
                    intent.setComponent(new ComponentName("com.google.android.apps.maps",
                            "com.google.android.maps.MapsActivity"));
                    startActivity(intent);
                }

                return false;
            }
        });

        return v1;
    } else if (position == 2) {
        View v1 = inflater.inflate(R.layout.event_info, container, false);
        v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        TextView t1 = (TextView) v1.findViewById(R.id.infotext);
        t1.setText(eformat);
        return v1;

    } else if (position == 3) {
        View v1 = inflater.inflate(R.layout.prize, container, false);
        v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        TextView t1 = (TextView) v1.findViewById(R.id.prizeText);
        t1.setText(eprize);
        return v1;

    } else if (position == 4) {
        v.setBackgroundColor(Color.GREEN);

    } else if (position == 5) {

        v.setBackgroundColor(Color.MAGENTA);

    } else if (position == 6) {
        v.setBackgroundColor(Color.MAGENTA);

    }
    fl.addView(v);
    return fl;

}