Example usage for android.widget TableLayout startAnimation

List of usage examples for android.widget TableLayout startAnimation

Introduction

In this page you can find the example usage for android.widget TableLayout startAnimation.

Prototype

public void startAnimation(Animation animation) 

Source Link

Document

Start the specified animation now.

Usage

From source file:org.ementasua.SwipeyTabFragment.java

private void buildList(LayoutInflater inflater, TableLayout tl, Menu menu, boolean what, Button lunch,
        Button dinner, ImageView ib) {
    View v = null;/*  w  w w  .j a va 2s.  c  o  m*/
    boolean t = true;
    String tmp = "";
    final String shareMsg;

    if (!what) {
        lunch.setBackgroundResource(R.drawable.table_menu_title_select);
        dinner.setBackgroundResource(R.drawable.table_menu_title_deselect);
        lunch.setClickable(false);
        dinner.setClickable(true);
        tmp = "Almo?o:\n";
    } else {
        lunch.setBackgroundResource(R.drawable.table_menu_title_deselect);
        dinner.setBackgroundResource(R.drawable.table_menu_title_select);
        lunch.setClickable(true);
        dinner.setClickable(false);
        tmp = "Jantar:\n";
    }

    Animation animation = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in);
    animation.setDuration(1000);

    tl.startAnimation(animation);
    tl.removeAllViews();

    if (!menu.isDisabled()) {
        for (Plate p : menu.getPlates()) {
            if (p.getName().length() > 0 && showPlate(p)) {
                v = buildRow(inflater, p);
                if (t)
                    v.setBackgroundResource(R.drawable.border1);
                else
                    v.setBackgroundResource(R.drawable.border2);
                t = !t;
                tl.addView(v);
            }
            if (p.getType().contains("Prato") && p.getName() != "" && p.getName().length() > 0) {
                tmp += p.getName() + "; ";
            }
        }
        ib.setVisibility(View.VISIBLE);
    } else {
        v = buildRow(inflater, new Plate("", menu.getDisabledText()));
        v.setBackgroundResource(R.drawable.border1);
        tl.addView(v);
        ib.setVisibility(View.GONE);
    }

    shareMsg = tmp;

    ib.setOnClickListener(new OnClickListener() {
        public void onClick(View arg0) {
            Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
            shareIntent.setType("text/plain");
            shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                    "Ementas do " + getArguments().getString("title"));
            String shareMessage = getArguments().getString("title") + " - " + shareMsg;
            shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage);
            startActivity(Intent.createChooser(shareIntent, "Partilhar para onde:"));
        }
    });
}