Example usage for android.widget TextView setLayoutParams

List of usage examples for android.widget TextView setLayoutParams

Introduction

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

Prototype

public void setLayoutParams(ViewGroup.LayoutParams params) 

Source Link

Document

Set the layout parameters associated with this view.

Usage

From source file:com.github.yggie.pulltorefresh.PullListFragment.java

/**
 * Called to do initial creation of the fragment. Creates all the Views in code
 *
 * @param inflater The LayoutInflater/*from ww  w. j  av a2  s  .c  om*/
 * @param container The parent container
 * @param savedInstanceState The saved pullState
 * @return The inflated view
 */

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();

    // setup the list view
    listView = new CustomListView(this);
    listView.setId(ID_LIST_VIEW);
    final RelativeLayout.LayoutParams listViewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    listViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    listViewParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    listView.setLayoutParams(listViewParams);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            onListItemClick((ListView) adapterView, view, position, id);
        }
    });

    // setup the empty view
    final TextView textView = new TextView(context);
    textView.setLayoutParams(listViewParams);
    textView.setGravity(Gravity.CENTER);
    textView.setText("Nothing to show");
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18.0f);
    emptyView = textView;
    emptyView.setId(ID_EMPTY_VIEW);

    // setup top pulled view
    final RelativeLayout.LayoutParams topViewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    topViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    topViewParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    final FrameLayout topFrameLayout = new FrameLayout(context);
    topFrameLayout.setLayoutParams(topViewParams);
    // setup the default child of the FrameLayout
    topManager = new DefaultPulledView(this, true);
    topFrameLayout.addView(topManager);
    topPulledView = topFrameLayout;
    topPulledView.setId(ID_TOP_VIEW);

    // setup bottom pulled view
    final RelativeLayout.LayoutParams bottomViewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    bottomViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    bottomViewParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    final FrameLayout bottomFrameLayout = new FrameLayout(context);
    bottomFrameLayout.setLayoutParams(bottomViewParams);
    // setup the default child in the FrameLayout
    bottomManager = new DefaultPulledView(this, false);
    bottomFrameLayout.addView(bottomManager);
    bottomPulledView = bottomFrameLayout;
    bottomPulledView.setId(ID_BOTTOM_VIEW);

    layout = new PullToRefreshLayout(this);
    layout.addView(topPulledView);
    layout.addView(bottomPulledView);
    layout.addView(listView);
    layout.addView(emptyView);
    layout.setId(ID_LAYOUT);

    listShown = false;
    listView.setVisibility(View.GONE);
    emptyView.setVisibility(View.VISIBLE);

    // applies the XML attributes, if exists
    if (attrs != null) {
        final TypedArray a = getActivity().obtainStyledAttributes(attrs, R.styleable.PullListFragment);
        if (a != null) {
            parseXmlAttributes(a);
            a.recycle();
        }
        attrs = null;
    }

    return layout;
}

From source file:com.customdatepicker.time.TimePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    int viewRes = mVersion == Version.VERSION_1 ? R.layout.mdtp_time_picker_dialog
            : R.layout.mdtp_time_picker_dialog_v2;
    View view = inflater.inflate(viewRes, container, false);
    KeyboardListener keyboardListener = new KeyboardListener();
    view.findViewById(R.id.mdtp_time_picker_dialog).setOnKeyListener(keyboardListener);

    // If an accent color has not been set manually, get it from the context
    if (mAccentColor == -1) {
        mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity());
    }/* w  w w  . j a v a 2s.  c om*/

    // if theme mode has not been set by java code, check if it is specified in Style.xml
    if (!mThemeDarkChanged) {
        mThemeDark = Utils.isDarkTheme(getActivity(), mThemeDark);
    }

    Resources res = getResources();
    Context context = getActivity();
    mHourPickerDescription = res.getString(R.string.mdtp_hour_picker_description);
    mSelectHours = res.getString(R.string.mdtp_select_hours);
    mMinutePickerDescription = res.getString(R.string.mdtp_minute_picker_description);
    mSelectMinutes = res.getString(R.string.mdtp_select_minutes);
    mSecondPickerDescription = res.getString(R.string.mdtp_second_picker_description);
    mSelectSeconds = res.getString(R.string.mdtp_select_seconds);
    mSelectedColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_accent_color_focused);

    mHourView = (TextView) view.findViewById(R.id.mdtp_hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourSpaceView = (TextView) view.findViewById(R.id.mdtp_hour_space);
    mMinuteSpaceView = (TextView) view.findViewById(R.id.mdtp_minutes_space);
    mMinuteView = (TextView) view.findViewById(R.id.mdtp_minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    mSecondSpaceView = (TextView) view.findViewById(R.id.mdtp_seconds_space);
    mSecondView = (TextView) view.findViewById(R.id.mdtp_seconds);
    mSecondView.setOnKeyListener(keyboardListener);
    mAmTextView = (TextView) view.findViewById(R.id.mdtp_am_label);
    mAmTextView.setOnKeyListener(keyboardListener);
    mPmTextView = (TextView) view.findViewById(R.id.mdtp_pm_label);
    mPmTextView.setOnKeyListener(keyboardListener);
    mAmPmLayout = view.findViewById(R.id.mdtp_ampm_layout);
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());

    if (mTimePicker != null) {
        mInitialTime = new Timepoint(mTimePicker.getHours(), mTimePicker.getMinutes(),
                mTimePicker.getSeconds());
    }

    mInitialTime = roundToNearest(mInitialTime);

    mTimePicker = (RadialPickerLayout) view.findViewById(R.id.mdtp_time_picker);
    mTimePicker.setOnValueSelectedListener(this);
    mTimePicker.setOnKeyListener(keyboardListener);
    mTimePicker.initialize(getActivity(), this, mInitialTime, mIs24HourMode);

    int currentItemShowing = HOUR_INDEX;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
        currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
    }
    setCurrentItemShowing(currentItemShowing, false, true, true);
    mTimePicker.invalidate();

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(HOUR_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(MINUTE_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mSecondView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            setCurrentItemShowing(SECOND_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mOkButton = (Button) view.findViewById(R.id.mdtp_ok);
    mOkButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInKbMode && isTypedTimeFullyLegal()) {
                finishKbMode(false);
            } else {
                tryVibrate();
            }
            notifyOnDateListener();
            dismiss();
        }
    });
    mOkButton.setOnKeyListener(keyboardListener);
    mOkButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium"));
    if (mOkString != null)
        mOkButton.setText(mOkString);
    else
        mOkButton.setText(mOkResid);

    mCancelButton = (Button) view.findViewById(R.id.mdtp_cancel);
    mCancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (getDialog() != null)
                getDialog().cancel();
        }
    });
    mCancelButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium"));
    if (mCancelString != null)
        mCancelButton.setText(mCancelString);
    else
        mCancelButton.setText(mCancelResid);
    mCancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE);

    // Enable or disable the AM/PM view.
    if (mIs24HourMode) {
        mAmPmLayout.setVisibility(View.GONE);
    } else {
        OnClickListener listener = new OnClickListener() {
            @Override
            public void onClick(View v) {
                // Don't do anything if either AM or PM are disabled
                if (isAmDisabled() || isPmDisabled())
                    return;

                tryVibrate();
                int amOrPm = mTimePicker.getIsCurrentlyAmOrPm();
                if (amOrPm == AM) {
                    amOrPm = PM;
                } else if (amOrPm == PM) {
                    amOrPm = AM;
                }
                mTimePicker.setAmOrPm(amOrPm);
            }
        };
        mAmTextView.setVisibility(View.GONE);
        mPmTextView.setVisibility(View.VISIBLE);
        mAmPmLayout.setOnClickListener(listener);
        if (mVersion == Version.VERSION_2) {
            mAmTextView.setText(mAmText);
            mPmTextView.setText(mPmText);
            mAmTextView.setVisibility(View.VISIBLE);
        }
        updateAmPmDisplay(mInitialTime.isAM() ? AM : PM);

    }

    // Disable seconds picker
    if (!mEnableSeconds) {
        mSecondView.setVisibility(View.GONE);
        view.findViewById(R.id.mdtp_separator_seconds).setVisibility(View.GONE);
    }

    // Disable minutes picker
    if (!mEnableMinutes) {
        mMinuteSpaceView.setVisibility(View.GONE);
        view.findViewById(R.id.mdtp_separator).setVisibility(View.GONE);
    }

    // Center stuff depending on what's visible
    boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    // Landscape layout is radically different
    if (isLandscape) {
        if (!mEnableMinutes && !mEnableSeconds) {
            // Just the hour
            // Put the hour above the center
            RelativeLayout.LayoutParams paramsHour = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsHour.addRule(RelativeLayout.ABOVE, R.id.mdtp_center_view);
            paramsHour.addRule(RelativeLayout.CENTER_HORIZONTAL);
            mHourSpaceView.setLayoutParams(paramsHour);
            if (mIs24HourMode) {
                // Hour + Am/Pm indicator
                // Put the am / pm indicator next to the hour
                RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(
                        ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                paramsAmPm.addRule(RelativeLayout.RIGHT_OF, R.id.mdtp_hour_space);
                mAmPmLayout.setLayoutParams(paramsAmPm);
            }
        } else if (!mEnableSeconds && mIs24HourMode) {
            // Hour + Minutes
            // Put the separator above the center
            RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL);
            paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_center_view);
            TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator);
            separatorView.setLayoutParams(paramsSeparator);
        } else if (!mEnableSeconds) {
            // Hour + Minutes + Am/Pm indicator
            // Put separator above the center
            RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL);
            paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_center_view);
            TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator);
            separatorView.setLayoutParams(paramsSeparator);
            // Put the am/pm indicator below the separator
            RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsAmPm.addRule(RelativeLayout.CENTER_IN_PARENT);
            paramsAmPm.addRule(RelativeLayout.BELOW, R.id.mdtp_center_view);
            mAmPmLayout.setLayoutParams(paramsAmPm);
        } else if (mIs24HourMode) {
            // Hour + Minutes + Seconds
            // Put the separator above the center
            RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL);
            paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_seconds_space);
            TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator);
            separatorView.setLayoutParams(paramsSeparator);
            // Center the seconds
            RelativeLayout.LayoutParams paramsSeconds = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeconds.addRule(RelativeLayout.CENTER_IN_PARENT);
            mSecondSpaceView.setLayoutParams(paramsSeconds);
        } else {
            // Hour + Minutes + Seconds + Am/Pm Indicator
            // Put the seconds on the center
            RelativeLayout.LayoutParams paramsSeconds = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeconds.addRule(RelativeLayout.CENTER_IN_PARENT);
            mSecondSpaceView.setLayoutParams(paramsSeconds);
            // Put the separator above the seconds
            RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL);
            paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_seconds_space);
            TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator);
            separatorView.setLayoutParams(paramsSeparator);
            // Put the Am/Pm indicator below the seconds
            RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsAmPm.addRule(RelativeLayout.CENTER_HORIZONTAL);
            paramsAmPm.addRule(RelativeLayout.BELOW, R.id.mdtp_seconds_space);
            mAmPmLayout.setLayoutParams(paramsAmPm);
        }
    } else if (mIs24HourMode && !mEnableSeconds && mEnableMinutes) {
        // center first separator
        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT);
        TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator);
        separatorView.setLayoutParams(paramsSeparator);
    } else if (!mEnableMinutes && !mEnableSeconds) {
        // center the hour
        RelativeLayout.LayoutParams paramsHour = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsHour.addRule(RelativeLayout.CENTER_IN_PARENT);
        mHourSpaceView.setLayoutParams(paramsHour);

        if (!mIs24HourMode) {
            RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            paramsAmPm.addRule(RelativeLayout.RIGHT_OF, R.id.mdtp_hour_space);
            paramsAmPm.addRule(RelativeLayout.ALIGN_BASELINE, R.id.mdtp_hour_space);
            mAmPmLayout.setLayoutParams(paramsAmPm);
        }
    } else if (mEnableSeconds) {
        // link separator to minutes
        final View separator = view.findViewById(R.id.mdtp_separator);
        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.LEFT_OF, R.id.mdtp_minutes_space);
        paramsSeparator.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
        separator.setLayoutParams(paramsSeparator);

        if (!mIs24HourMode) {
            // center minutes
            RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            paramsMinutes.addRule(RelativeLayout.CENTER_IN_PARENT);
            mMinuteSpaceView.setLayoutParams(paramsMinutes);
        } else {
            // move minutes to right of center
            RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            paramsMinutes.addRule(RelativeLayout.RIGHT_OF, R.id.mdtp_center_view);
            mMinuteSpaceView.setLayoutParams(paramsMinutes);
        }
    }

    mAllowAutoAdvance = true;
    setHour(mInitialTime.getHour(), true);
    setMinute(mInitialTime.getMinute());
    setSecond(mInitialTime.getSecond());

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.mdtp_time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.mdtp_deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();
    if (mInKbMode) {
        mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES);
        tryStartingKbMode(-1);
        mHourView.invalidate();
    } else if (mTypedTimes == null) {
        mTypedTimes = new ArrayList<>();
    }

    // Set the title (if any)
    TextView timePickerHeader = (TextView) view.findViewById(R.id.mdtp_time_picker_header);
    if (!mTitle.isEmpty()) {
        timePickerHeader.setVisibility(TextView.VISIBLE);
        timePickerHeader.setText(mTitle.toUpperCase(Locale.getDefault()));
    }

    // Set the theme at the end so that the initialize()s above don't counteract the theme.
    timePickerHeader.setBackgroundColor(Utils.darkenColor(mAccentColor));
    view.findViewById(R.id.mdtp_time_display_background).setBackgroundColor(mAccentColor);
    view.findViewById(R.id.mdtp_time_display).setBackgroundColor(mAccentColor);

    // Button text can have a different color
    if (mOkColor != -1)
        mOkButton.setTextColor(mOkColor);
    else
        mOkButton.setTextColor(mAccentColor);
    if (mCancelColor != -1)
        mCancelButton.setTextColor(mCancelColor);
    else
        mCancelButton.setTextColor(mAccentColor);

    if (getDialog() == null) {
        view.findViewById(R.id.mdtp_done_background).setVisibility(View.GONE);
    }

    int circleBackground = ContextCompat.getColor(context, R.color.mdtp_circle_background);
    int backgroundColor = ContextCompat.getColor(context, R.color.mdtp_background_color);
    int darkBackgroundColor = ContextCompat.getColor(context, R.color.mdtp_light_gray);
    int lightGray = ContextCompat.getColor(context, R.color.mdtp_light_gray);

    mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground);
    view.findViewById(R.id.mdtp_time_picker_dialog)
            .setBackgroundColor(mThemeDark ? darkBackgroundColor : backgroundColor);
    return view;
}

From source file:com.citrus.sample.WalletPaymentFragment.java

void showTokenizedPrompt() {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    final String message = "Auto Load Money with Saved Card";
    String positiveButtonText = "Auto Load";

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    final TextView labelamt = new TextView(getActivity());
    final EditText editAmount = new EditText(getActivity());
    final TextView labelAmount = new TextView(getActivity());
    final EditText editLoadAmount = new EditText(getActivity());
    final TextView labelMobileNo = new TextView(getActivity());
    final EditText editThresholdAmount = new EditText(getActivity());
    final Button btnSelectSavedCards = new Button(getActivity());
    btnSelectSavedCards.setText("Select Saved Card");

    editLoadAmount.setSingleLine(true);/*from w ww. j  a va2s  .c  om*/
    editThresholdAmount.setSingleLine(true);

    editAmount.setSingleLine(true);
    labelamt.setText("Load Amount");
    labelAmount.setText("Auto Load Amount");
    labelMobileNo.setText("Threshold Amount");

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    labelamt.setLayoutParams(layoutParams);
    editAmount.setLayoutParams(layoutParams);
    labelAmount.setLayoutParams(layoutParams);
    labelMobileNo.setLayoutParams(layoutParams);
    editLoadAmount.setLayoutParams(layoutParams);
    editThresholdAmount.setLayoutParams(layoutParams);
    btnSelectSavedCards.setLayoutParams(layoutParams);

    btnSelectSavedCards.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mCitrusClient.getWallet(new Callback<List<PaymentOption>>() {
                @Override
                public void success(List<PaymentOption> paymentOptions) {
                    walletList.clear();
                    for (PaymentOption paymentOption : paymentOptions) {
                        if (paymentOption instanceof CreditCardOption) {
                            if (Arrays.asList(AUTO_LOAD_CARD_SCHEMS)
                                    .contains(((CardOption) paymentOption).getCardScheme().toString()))
                                walletList.add(paymentOption); //only available for Master and Visa Credit Card....
                        }
                    }
                    savedOptionsAdapter = new SavedOptionsAdapter(getActivity(), walletList);
                    showSavedAccountsDialog();
                }

                @Override
                public void error(CitrusError error) {
                    Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show();
                }
            });
        }
    });

    linearLayout.addView(labelamt);
    linearLayout.addView(editAmount);
    linearLayout.addView(labelAmount);
    linearLayout.addView(editLoadAmount);
    linearLayout.addView(labelMobileNo);
    linearLayout.addView(editThresholdAmount);
    linearLayout.addView(btnSelectSavedCards);

    int paddingPx = Utils.getSizeInPx(getActivity(), 32);
    linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);

    editLoadAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    editThresholdAmount.setInputType(InputType.TYPE_CLASS_NUMBER);
    alert.setTitle("Auto Load Money with Saved Card");
    alert.setMessage(message);

    alert.setView(linearLayout);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            final String amount = editAmount.getText().toString();
            final String loadAmount = editLoadAmount.getText().toString();
            final String thresHoldAmount = editThresholdAmount.getText().toString();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(editAmount.getWindowToken(), 0);

            if (TextUtils.isEmpty(amount)) {
                Toast.makeText(getActivity(), "Amount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (TextUtils.isEmpty(loadAmount)) {
                Toast.makeText(getActivity(), "Load Amount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (TextUtils.isEmpty(thresHoldAmount)) {
                Toast.makeText(getActivity(), "thresHoldAmount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (Double.valueOf(thresHoldAmount) < new Double("500")) {
                Toast.makeText(getActivity(), "thresHoldAmount  should not be less than 500",
                        Toast.LENGTH_SHORT).show();
                return;
            }

            if (Double.valueOf(loadAmount) < new Double(thresHoldAmount)) {
                Toast.makeText(getActivity(), "Load Amount should not be less than thresHoldAmount",
                        Toast.LENGTH_SHORT).show();
                return;
            }

            if (otherPaymentOption == null) {
                Toast.makeText(getActivity(), "Saved Card Option is null.", Toast.LENGTH_SHORT).show();
            }

            try {
                PaymentType paymentType = new PaymentType.LoadMoney(new Amount(amount), otherPaymentOption);
                mCitrusClient.autoLoadMoney((PaymentType.LoadMoney) paymentType, new Amount(thresHoldAmount),
                        new Amount(loadAmount), new Callback<SubscriptionResponse>() {
                            @Override
                            public void success(SubscriptionResponse subscriptionResponse) {
                                Logger.d("AUTO LOAD RESPONSE ***"
                                        + subscriptionResponse.getSubscriptionResponseMessage());
                                Toast.makeText(getActivity(),
                                        subscriptionResponse.getSubscriptionResponseMessage(),
                                        Toast.LENGTH_SHORT).show();
                            }

                            @Override
                            public void error(CitrusError error) {
                                Logger.d("AUTO LOAD ERROR ***" + error.getMessage());
                                Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show();
                            }
                        });
            } catch (CitrusException e) {
                e.printStackTrace();
            }
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    editLoadAmount.requestFocus();
    alert.show();
}

From source file:com.derrick.movies.MovieDetailsActivity.java

private void setTrailers(Videos videos) {
    videosList = videos.getResults();/*  ww  w.j  a va  2 s . c  o m*/
    int size = videosList.size();
    if (size == 1) {
        txt_title_trailer.setText("Trailer");
    }

    for (int i = 0; i < size; i++) {

        Result result = videosList.get(i);
        String url = IMAGE_YOUTUBE + result.getKey() + YOUTUBE_QUALITY;
        ImageView imageView;
        ImageView imageView_play;
        TextView txt_name;

        ViewGroup.LayoutParams lp = new RelativeLayout.LayoutParams(70, 70);
        ViewGroup.LayoutParams lp2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT);

        RelativeLayout relativeLayout = new RelativeLayout(this);
        relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
                RelativeLayout.LayoutParams.MATCH_PARENT));

        if (size == 1) {
            imageView = new ImageView(getApplicationContext());
            imageView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

        } else {
            imageView = new ImageView(getApplicationContext());
            imageView
                    .setLayoutParams(new RelativeLayout.LayoutParams(500, ViewGroup.LayoutParams.MATCH_PARENT));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        }

        imageView_play = new ImageView(getApplicationContext());
        imageView_play.setLayoutParams(lp);
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) imageView_play
                .getLayoutParams();
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
        imageView_play.setLayoutParams(layoutParams);
        imageView_play.setScaleType(ImageView.ScaleType.CENTER_CROP);
        Drawable drawable = getResources()
                .getDrawable(getResources().getIdentifier("play", "drawable", getPackageName()));
        imageView_play.setImageDrawable(drawable);

        txt_name = new TextView(getApplicationContext());
        txt_name.setLayoutParams(lp2);
        RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) txt_name.getLayoutParams();
        layoutParams2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
        layoutParams2.setMargins(8, 8, 8, 16);
        txt_name.setLayoutParams(layoutParams2);
        txt_name.setTypeface(robotoCondensed);
        txt_name.setText(result.getName());
        txt_name.setTextColor(getResources().getColor(R.color.colorWhite));

        Glide.with(getBaseContext()).load(url).diskCacheStrategy(DiskCacheStrategy.ALL)
                .listener(new RequestListener<String, GlideDrawable>() {
                    @Override
                    public boolean onException(Exception e, String model, Target<GlideDrawable> target,
                            boolean isFirstResource) {
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(GlideDrawable resource, String model,
                            Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {

                        return false;
                    }
                }).into(imageView);

        // trailerSlider.addView(imageView_play);
        relativeLayout.addView(imageView);
        relativeLayout.addView(imageView_play);
        relativeLayout.addView(txt_name);
        trailerSlider.addView(relativeLayout);

    }

}

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showCashoutPrompt() {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    String message = "Please enter account details.";
    String positiveButtonText = "Withdraw";

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    final TextView labelAmount = new TextView(getActivity());
    final EditText editAmount = new EditText(getActivity());
    final TextView labelAccountNo = new TextView(getActivity());
    final EditText editAccountNo = new EditText(getActivity());
    editAccountNo.setSingleLine(true);/*  w  ww  . j  a v  a  2s.c  om*/
    final TextView labelAccountHolderName = new TextView(getActivity());
    final EditText editAccountHolderName = new EditText(getActivity());
    editAccountHolderName.setSingleLine(true);
    final TextView labelIfscCode = new TextView(getActivity());
    final EditText editIfscCode = new EditText(getActivity());
    editIfscCode.setSingleLine(true);

    labelAmount.setText("Withdrawal Amount");
    labelAccountNo.setText("Account Number");
    labelAccountHolderName.setText("Account Holder Name");
    labelIfscCode.setText("IFSC Code");

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    labelAmount.setLayoutParams(layoutParams);
    labelAccountNo.setLayoutParams(layoutParams);
    labelAccountHolderName.setLayoutParams(layoutParams);
    labelIfscCode.setLayoutParams(layoutParams);
    editAmount.setLayoutParams(layoutParams);
    editAccountNo.setLayoutParams(layoutParams);
    editAccountHolderName.setLayoutParams(layoutParams);
    editIfscCode.setLayoutParams(layoutParams);

    linearLayout.addView(labelAmount);
    linearLayout.addView(editAmount);
    linearLayout.addView(labelAccountNo);
    linearLayout.addView(editAccountNo);
    linearLayout.addView(labelAccountHolderName);
    linearLayout.addView(editAccountHolderName);
    linearLayout.addView(labelIfscCode);
    linearLayout.addView(editIfscCode);

    int paddingPx = Utils.getSizeInPx(getActivity(), 32);
    linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);

    editAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);

    alert.setTitle("Withdraw Money To Your Account");
    alert.setMessage(message);

    alert.setView(linearLayout);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String amount = editAmount.getText().toString();
            String accontNo = editAccountNo.getText().toString();
            String accountHolderName = editAccountHolderName.getText().toString();
            String ifsc = editIfscCode.getText().toString();

            CashoutInfo cashoutInfo = new CashoutInfo(new Amount(amount), accontNo, accountHolderName, ifsc);
            mListener.onCashoutSelected(cashoutInfo);

            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(editAmount.getWindowToken(), 0);
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    editAmount.requestFocus();
    alert.show();
}

From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java

public void showchecksdialog() {
    Boolean passedchecks = false;
    String PositiveButtonString;/*  w  ww.  j  a  va2s .co m*/
    String DisplayChecksOrPassedString;
    String ListChecksString = dochecks();
    String Title;

    if (ListChecksString.trim().length() == 0) {
        passedchecks = true;
    }
    if (passedchecks) {
        DisplayChecksOrPassedString = "Are you sure your finished editing floorplans?";
        Title = "Exit";
        PositiveButtonString = "OK";
    } else {
        DisplayChecksOrPassedString = "You have outstanding issues with this floorplan, please correct these issues before exiting.";
        Title = "Outstanding Issues!";
        PositiveButtonString = "IGNORE & EXIT";
    }

    TextView showfailedcheckstv;
    showfailedcheckstv = new TextView(this);
    showfailedcheckstv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    showfailedcheckstv.setText(ListChecksString);
    showfailedcheckstv.setPadding(5, 5, 5, 5);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(Title).setMessage(DisplayChecksOrPassedString).setView(showfailedcheckstv)
            .setCancelable(false).setIcon(R.drawable.ic_launcher)
            .setPositiveButton(PositiveButtonString, new DialogInterface.OnClickListener() {

                @Override

                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub

                    balmvalues();
                    new SaveTask(progressDialog).execute();
                    try {
                        sethourglassicons();
                    } catch (Throwable e) {

                    }
                    finish();
                    System.gc();
                    dialog.dismiss();
                    finish();
                }

            }).setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            }).setCancelable(true);

    getscaledialog = builder.create();
    getscaledialog.show();

}

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showUpdateSubscriptionPrompt(final boolean isUpdateToHigherValue) {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    //    final String message = "Update Subscription to Lowe Amount";
    String positiveButtonText = "Update Subscription ";

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    final TextView labelsubscriptionID = new TextView(getActivity());
    final EditText edtAmount = new EditText(getActivity());
    final TextView labelAmount = new TextView(getActivity());
    final EditText editLoadAmount = new EditText(getActivity());
    final TextView labelMobileNo = new TextView(getActivity());
    final EditText editThresholdAmount = new EditText(getActivity());

    editLoadAmount.setSingleLine(true);//ww w  . j a  v  a  2s  .  c om
    editThresholdAmount.setSingleLine(true);
    edtAmount.setSingleLine(true);
    edtAmount.setInputType(InputType.TYPE_NULL);
    labelsubscriptionID.setText("Load Money Amount");
    labelAmount.setText("Current Auto Load Amount");
    editLoadAmount.setText(String.valueOf(activeSubscription.getLoadAmount()));
    labelMobileNo.setText("Current Threshold Amount");
    editThresholdAmount.setText(String.valueOf(activeSubscription.getThresholdAmount()));

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    labelsubscriptionID.setLayoutParams(layoutParams);
    edtAmount.setLayoutParams(layoutParams);
    labelAmount.setLayoutParams(layoutParams);
    labelMobileNo.setLayoutParams(layoutParams);
    editLoadAmount.setLayoutParams(layoutParams);
    editThresholdAmount.setLayoutParams(layoutParams);

    linearLayout.addView(labelAmount);
    linearLayout.addView(editLoadAmount);
    linearLayout.addView(labelMobileNo);
    linearLayout.addView(editThresholdAmount);
    linearLayout.addView(labelsubscriptionID);
    linearLayout.addView(edtAmount);
    edtAmount.setText("1.00");

    int paddingPx = Utils.getSizeInPx(getActivity(), 32);
    linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);

    editLoadAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    edtAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    editLoadAmount.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            /* if (!hasFocus) {
            if (Double.valueOf(editLoadAmount.getText().toString()) > activeSubscription.getLoadAmount()) {
                labelsubscriptionID.setVisibility(View.VISIBLE);
                edtAmount.setVisibility(View.VISIBLE);
                edtAmount.setText("1.00");
                    
            } else {
                labelsubscriptionID.setVisibility(View.INVISIBLE);
                edtAmount.setVisibility(View.INVISIBLE);
            }
             }*/
        }
    });
    editThresholdAmount.setInputType(InputType.TYPE_CLASS_NUMBER);
    alert.setTitle("Update Subscription ");
    alert.setMessage("Updating Load amount to higher will require Load Money transactions.");

    alert.setView(linearLayout);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            final String trAmount = edtAmount.getText().toString();

            final String loadAmount = editLoadAmount.getText().toString();
            final String thresHoldAmount = editThresholdAmount.getText().toString();

            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(edtAmount.getWindowToken(), 0);

            if (TextUtils.isEmpty(trAmount) && edtAmount.getVisibility() == View.VISIBLE) {
                Toast.makeText(getActivity(), " load amount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (TextUtils.isEmpty(loadAmount)) {
                Toast.makeText(getActivity(), "Auto Load Amount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (TextUtils.isEmpty(thresHoldAmount)) {
                Toast.makeText(getActivity(), "thresHoldAmount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (Double.valueOf(thresHoldAmount) < new Double("500")) {
                Toast.makeText(getActivity(), "thresHoldAmount  should not be less than 500",
                        Toast.LENGTH_SHORT).show();
                return;
            }

            if (Double.valueOf(loadAmount) < new Double(thresHoldAmount)) {
                Toast.makeText(getActivity(), "Load Amount should not be less than thresHoldAmount",
                        Toast.LENGTH_SHORT).show();
                return;
            }
            if (Double.valueOf(editLoadAmount.getText().toString()) > activeSubscription.getLoadAmount()) { //update to higher value
                mListener.onAutoLoadSelected(AUTO_LOAD_MONEY, new Amount(trAmount),
                        editLoadAmount.getText().toString(), editThresholdAmount.getText().toString(), true);
            } else { //update to lower value
                mCitrusClient.updateSubScriptiontoLoweValue(new Amount(thresHoldAmount), new Amount(loadAmount),
                        new Callback<SubscriptionResponse>() {
                            @Override
                            public void success(SubscriptionResponse subscriptionResponse) {
                                Toast.makeText(getActivity(), subscriptionResponse.toString(),
                                        Toast.LENGTH_SHORT).show();

                                Logger.d("updateSubscription response **" + subscriptionResponse.toString());
                                activeSubscription = subscriptionResponse;//update the active subscription Object
                            }

                            @Override
                            public void error(CitrusError error) {
                                Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show();
                                Logger.d("ERROR ***updateSubscription" + error.getMessage());
                            }
                        });
            }
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    editLoadAmount.requestFocus();
    alert.show();
}

From source file:com.vonglasow.michael.satstat.MainActivity.java

private final void addWifiResult(ScanResult result) {
    final ScanResult r = result;
    android.view.View.OnClickListener clis = new android.view.View.OnClickListener() {

        @Override//from  w  w  w .  ja  v a  2s.c o m
        public void onClick(View v) {
            onWifiEntryClick(r.BSSID);
        }
    };

    View divider = new View(wifiAps.getContext());
    divider.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, 1));
    divider.setBackgroundColor(getResources().getColor(android.R.color.tertiary_text_dark));
    divider.setOnClickListener(clis);
    wifiAps.addView(divider);

    LinearLayout wifiLayout = new LinearLayout(wifiAps.getContext());
    wifiLayout.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    wifiLayout.setOrientation(LinearLayout.HORIZONTAL);
    wifiLayout.setWeightSum(22);
    wifiLayout.setMeasureWithLargestChildEnabled(false);

    ImageView wifiType = new ImageView(wifiAps.getContext());
    wifiType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.MATCH_PARENT, 3));
    if (WifiCapabilities.isAdhoc(result)) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_adhoc);
    } else if ((WifiCapabilities.isEnterprise(result))
            || (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.EAP)) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_eap);
    } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.PSK) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_psk);
    } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.WEP) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_wep);
    } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.OPEN) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_open);
    } else {
        wifiType.setImageResource(R.drawable.ic_content_wifi_unknown);
    }

    wifiType.setScaleType(ScaleType.CENTER);
    wifiLayout.addView(wifiType);

    TableLayout wifiDetails = new TableLayout(wifiAps.getContext());
    wifiDetails.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
    TableRow innerRow1 = new TableRow(wifiAps.getContext());
    TextView newMac = new TextView(wifiAps.getContext());
    newMac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 14));
    newMac.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
    newMac.setText(result.BSSID);
    innerRow1.addView(newMac);
    TextView newCh = new TextView(wifiAps.getContext());
    newCh.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
    newCh.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
    newCh.setText(getChannelFromFrequency(result.frequency));
    innerRow1.addView(newCh);
    TextView newLevel = new TextView(wifiAps.getContext());
    newLevel.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newLevel.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
    newLevel.setText(String.valueOf(result.level));
    innerRow1.addView(newLevel);
    innerRow1.setOnClickListener(clis);
    wifiDetails.addView(innerRow1,
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    TableRow innerRow2 = new TableRow(wifiAps.getContext());
    TextView newSSID = new TextView(wifiAps.getContext());
    newSSID.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
    newSSID.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Small);
    newSSID.setText(result.SSID);
    innerRow2.addView(newSSID);
    innerRow2.setOnClickListener(clis);
    wifiDetails.addView(innerRow2,
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    wifiLayout.addView(wifiDetails);
    wifiLayout.setOnClickListener(clis);
    wifiAps.addView(wifiLayout);
}

From source file:org.smilec.smile.student.CourseList.java

private void createScoreTable(Vector<Integer> _myscore, String username) {

    int num_right = countrightquestion(_myscore);
    int total_question = LAST_SCENE_NUM;

    TableLayout tl = (TableLayout) findViewById(R.id.tableLayoutSeeR);
    TextView text1 = (TextView) findViewById(R.id.Header01);
    text1.setText(getString(R.string.name) + ": " + username);
    TextView text2 = (TextView) findViewById(R.id.Header11);
    text2.setText(getString(R.string.t_score) + ":" + num_right + "/" + total_question);

    for (int i = 0; i < _myscore.size(); i++) {
        TableRow tr = new TableRow(getApplicationContext());
        tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                TableRow.LayoutParams.WRAP_CONTENT));
        int number = 0;
        number = i + 1;/*from w w  w .j  av  a2s.c  o m*/
        int score = _myscore.get(i);

        Button b = new Button(getApplicationContext());
        b.setText("(" + number + ")");
        b.setTextSize(resultSize1);
        // b.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
        TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                TableRow.LayoutParams.WRAP_CONTENT);
        params.setMargins(returnPixels(30.0f), 0, returnPixels(30.0f), 0);
        b.setLayoutParams(params);
        b.setOnClickListener(new MyButtonListener(number));

        /* Add Button to row. */
        tr.addView(b);
        TextView text = new TextView(getApplicationContext());

        if (score == 1) { // right
            text.setText("0");
        } else { // wrong
            text.setText("X");
        }
        text.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                TableRow.LayoutParams.WRAP_CONTENT));
        text.setTextColor(Color.BLACK);
        text.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
        text.setTextSize(resultSize2);
        tr.addView(text);

        //tr.setBackgroundResource(R.drawable.sf_gradient_03);
        tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,
                TableLayout.LayoutParams.WRAP_CONTENT));

    }

    return;
}

From source file:com.android.calendar.selectcalendars.SelectCalendarsSimpleAdapter.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    if (position >= mRowCount) {
        return null;
    }//from   w  w  w .  j a  v a 2 s . co  m
    String name = mData[position].displayName;
    boolean selected = mData[position].selected;

    int color = Utils.getDisplayColorFromColor(mData[position].color);
    View view;
    if (convertView == null) {
        view = mInflater.inflate(mLayout, parent, false);
        final View delegate = view.findViewById(R.id.color);
        final View delegateParent = (View) delegate.getParent();
        delegateParent.post(new Runnable() {

            @Override
            public void run() {
                final Rect r = new Rect();
                delegate.getHitRect(r);
                r.top -= mColorViewTouchAreaIncrease;
                r.bottom += mColorViewTouchAreaIncrease;
                r.left -= mColorViewTouchAreaIncrease;
                r.right += mColorViewTouchAreaIncrease;
                delegateParent.setTouchDelegate(new TouchDelegate(r, delegate));
            }
        });
    } else {
        view = convertView;
    }

    TextView calendarName = (TextView) view.findViewById(R.id.calendar);
    calendarName.setText(name);

    View colorView = view.findViewById(R.id.color);
    colorView.setBackgroundColor(color);
    colorView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // Purely for sanity check--view should be disabled if account has no more colors
            if (!hasMoreColors(position)) {
                return;
            }

            if (mColorPickerDialog == null) {
                mColorPickerDialog = CalendarColorPickerDialog.newInstance(mData[position].id, mIsTablet);
            } else {
                mColorPickerDialog.setCalendarId(mData[position].id);
            }
            mFragmentManager.executePendingTransactions();
            if (!mColorPickerDialog.isAdded()) {
                mColorPickerDialog.show(mFragmentManager, COLOR_PICKER_DIALOG_TAG);
            }
        }
    });

    int textColor;
    if (selected) {
        textColor = mColorCalendarVisible;
    } else {
        textColor = mColorCalendarHidden;
    }
    calendarName.setTextColor(textColor);

    CheckBox syncCheckBox = (CheckBox) view.findViewById(R.id.sync);
    if (syncCheckBox != null) {

        // Full screen layout
        syncCheckBox.setChecked(selected);

        colorView.setEnabled(hasMoreColors(position));
        LayoutParams layoutParam = calendarName.getLayoutParams();
        TextView secondaryText = (TextView) view.findViewById(R.id.status);
        if (!TextUtils.isEmpty(mData[position].ownerAccount) && !mData[position].ownerAccount.equals(name)
                && !mData[position].ownerAccount.endsWith("calendar.google.com")) {
            int secondaryColor;
            if (selected) {
                secondaryColor = mColorCalendarSecondaryVisible;
            } else {
                secondaryColor = mColorCalendarSecondaryHidden;
            }
            secondaryText.setText(mData[position].ownerAccount);
            secondaryText.setTextColor(secondaryColor);
            secondaryText.setVisibility(View.VISIBLE);
            layoutParam.height = LayoutParams.WRAP_CONTENT;
        } else {
            secondaryText.setVisibility(View.GONE);
            layoutParam.height = LayoutParams.MATCH_PARENT;
        }

        calendarName.setLayoutParams(layoutParam);

    } else {
        // Tablet layout
        view.findViewById(R.id.color).setEnabled(selected && hasMoreColors(position));
        view.setBackgroundDrawable(getBackground(position, selected));
        ViewGroup.LayoutParams newParams = view.getLayoutParams();
        if (position == mData.length - 1) {
            newParams.height = BOTTOM_ITEM_HEIGHT;
        } else {
            newParams.height = NORMAL_ITEM_HEIGHT;
        }
        view.setLayoutParams(newParams);
        CheckBox visibleCheckBox = (CheckBox) view.findViewById(R.id.visible_check_box);
        if (visibleCheckBox != null) {
            visibleCheckBox.setChecked(selected);
        }
    }
    view.invalidate();
    return view;
}