Search in sources :

Example 41 with TextView

use of android.widget.TextView in project cw-omnibus by commonsguy.

the class PrefsPersistActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    int counter = prefs.getInt(KEY, 0);
    ((TextView) findViewById(R.id.value)).setText(String.valueOf(counter));
    AbstractPrefsPersistStrategy.persist(prefs.edit().putInt(KEY, counter + 1));
}
Also used : SharedPreferences(android.content.SharedPreferences) TextView(android.widget.TextView)

Example 42 with TextView

use of android.widget.TextView in project cw-omnibus by commonsguy.

the class OtherActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.other);
    TextView tv = (TextView) findViewById(R.id.msg);
    tv.setText(getIntent().getStringExtra(EXTRA_MESSAGE));
}
Also used : TextView(android.widget.TextView)

Example 43 with TextView

use of android.widget.TextView in project cw-omnibus by commonsguy.

the class IcsToast method makeText.

public static Toast makeText(Context context, CharSequence s, int duration) {
    if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
        return Toast.makeText(context, s, duration);
    }
    IcsToast toast = new IcsToast(context);
    toast.setDuration(duration);
    TextView view = new TextView(context);
    view.setText(s);
    // Original AOSP using reference on @android:color/bright_foreground_dark
    // bright_foreground_dark - reference on @android:color/background_light
    // background_light - 0xffffffff
    view.setTextColor(0xffffffff);
    view.setGravity(Gravity.CENTER);
    view.setBackgroundResource(R.drawable.abs__toast_frame);
    toast.setView(view);
    return toast;
}
Also used : TextView(android.widget.TextView)

Example 44 with TextView

use of android.widget.TextView in project Calligraphy by chrisjenx.

the class CalligraphyFactory method onViewCreatedInternal.

void onViewCreatedInternal(View view, final Context context, AttributeSet attrs) {
    if (view instanceof TextView) {
        // TextView's inside the Toolbar/ActionBar).
        if (TypefaceUtils.isLoaded(((TextView) view).getTypeface())) {
            return;
        }
        // Try to get typeface attribute value
        // Since we're not using namespace it's a little bit tricky
        // Check xml attrs, style attrs and text appearance for font path
        String textViewFont = resolveFontPath(context, attrs);
        // Try theme attributes
        if (TextUtils.isEmpty(textViewFont)) {
            final int[] styleForTextView = getStyleForTextView((TextView) view);
            if (styleForTextView[1] != -1)
                textViewFont = CalligraphyUtils.pullFontPathFromTheme(context, styleForTextView[0], styleForTextView[1], mAttributeId);
            else
                textViewFont = CalligraphyUtils.pullFontPathFromTheme(context, styleForTextView[0], mAttributeId);
        }
        // Still need to defer the Native action bar, appcompat-v7:21+ uses the Toolbar underneath. But won't match these anyway.
        final boolean deferred = matchesResourceIdName(view, ACTION_BAR_TITLE) || matchesResourceIdName(view, ACTION_BAR_SUBTITLE);
        CalligraphyUtils.applyFontToTextView(context, (TextView) view, CalligraphyConfig.get(), textViewFont, deferred);
    }
    // Toolbar(Which underlies the ActionBar) for its children.
    if (CalligraphyUtils.canCheckForV7Toolbar() && view instanceof android.support.v7.widget.Toolbar) {
        final Toolbar toolbar = (Toolbar) view;
        toolbar.getViewTreeObserver().addOnGlobalLayoutListener(new ToolbarLayoutListener(this, context, toolbar));
    }
    // Try to set typeface for custom views using interface method or via reflection if available
    if (view instanceof HasTypeface) {
        Typeface typeface = getDefaultTypeface(context, resolveFontPath(context, attrs));
        if (typeface != null) {
            ((HasTypeface) view).setTypeface(typeface);
        }
    } else if (CalligraphyConfig.get().isCustomViewTypefaceSupport() && CalligraphyConfig.get().isCustomViewHasTypeface(view)) {
        final Method setTypeface = ReflectionUtils.getMethod(view.getClass(), "setTypeface");
        String fontPath = resolveFontPath(context, attrs);
        Typeface typeface = getDefaultTypeface(context, fontPath);
        if (setTypeface != null && typeface != null) {
            ReflectionUtils.invokeMethod(view, setTypeface, typeface);
        }
    }
}
Also used : Toolbar(android.support.v7.widget.Toolbar) Typeface(android.graphics.Typeface) TextView(android.widget.TextView) Method(java.lang.reflect.Method) Toolbar(android.support.v7.widget.Toolbar)

Example 45 with TextView

use of android.widget.TextView in project android-betterpickers by code-troopers.

the class CalendarDatePickerDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");
    if (getShowsDialog()) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    }
    View view = inflater.inflate(R.layout.calendar_date_picker_dialog, container, false);
    mSelectedDateLayout = (LinearLayout) view.findViewById(R.id.day_picker_selected_date_layout);
    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);
    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinDate = new CalendarDay(savedInstanceState.getLong(KEY_DATE_START));
        mMaxDate = new CalendarDay(savedInstanceState.getLong(KEY_DATE_END));
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
        mStyleResId = savedInstanceState.getInt(KEY_THEME);
        mDisabledDays = savedInstanceState.getSparseParcelableArray(KEY_DISABLED_DAYS);
    }
    final Activity activity = getActivity();
    mDayPickerView = new SimpleDayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);
    Resources res = getResources();
    TypedArray themeColors = getActivity().obtainStyledAttributes(mStyleResId, R.styleable.BetterPickersDialogs);
    mDayPickerDescription = res.getString(R.string.day_picker_description);
    mSelectDay = res.getString(R.string.select_day);
    mYearPickerDescription = res.getString(R.string.year_picker_description);
    mSelectYear = res.getString(R.string.select_year);
    int headerBackgroundColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int preHeaderBackgroundColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpPreHeaderBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int bodyBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpBodyBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int buttonBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int buttonTextColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsTextColor, ContextCompat.getColor(getActivity(), R.color.bpBlue));
    mSelectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderSelectedTextColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
    mUnselectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderUnselectedTextColor, ContextCompat.getColor(getActivity(), R.color.radial_gray_light));
    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);
    Button doneButton = (Button) view.findViewById(R.id.done_button);
    if (mDoneText != null) {
        doneButton.setText(mDoneText);
    }
    doneButton.setTextColor(buttonTextColor);
    doneButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            if (mCallBack != null) {
                mCallBack.onDateSet(CalendarDatePickerDialogFragment.this, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
            }
            dismiss();
        }
    });
    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
    if (mCancelText != null) {
        cancelButton.setText(mCancelText);
    }
    cancelButton.setTextColor(buttonTextColor);
    cancelButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            dismiss();
        }
    });
    view.findViewById(R.id.ok_cancel_buttons_layout).setBackgroundColor(buttonBgColor);
    updateDisplay(false);
    setCurrentView(currentView);
    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }
    mHapticFeedbackController = new HapticFeedbackController(activity);
    mDayPickerView.setTheme(themeColors);
    mYearPickerView.setTheme(themeColors);
    mSelectedDateLayout.setBackgroundColor(headerBackgroundColor);
    mYearView.setBackgroundColor(headerBackgroundColor);
    mMonthAndDayView.setBackgroundColor(headerBackgroundColor);
    if (mDayOfWeekView != null) {
        mDayOfWeekView.setBackgroundColor(preHeaderBackgroundColor);
    }
    view.setBackgroundColor(bodyBgColor);
    mYearPickerView.setBackgroundColor(bodyBgColor);
    mDayPickerView.setBackgroundColor(bodyBgColor);
    return view;
}
Also used : Activity(android.app.Activity) View(android.view.View) TextView(android.widget.TextView) AlphaAnimation(android.view.animation.AlphaAnimation) Button(android.widget.Button) TypedArray(android.content.res.TypedArray) Animation(android.view.animation.Animation) AlphaAnimation(android.view.animation.AlphaAnimation) OnClickListener(android.view.View.OnClickListener) HapticFeedbackController(com.codetroopers.betterpickers.HapticFeedbackController) Resources(android.content.res.Resources) CalendarDay(com.codetroopers.betterpickers.calendardatepicker.MonthAdapter.CalendarDay)

Aggregations

TextView (android.widget.TextView)4784 View (android.view.View)2545 ImageView (android.widget.ImageView)1082 Button (android.widget.Button)423 LinearLayout (android.widget.LinearLayout)417 LayoutInflater (android.view.LayoutInflater)401 ListView (android.widget.ListView)375 Intent (android.content.Intent)367 AdapterView (android.widget.AdapterView)356 ViewGroup (android.view.ViewGroup)314 OnClickListener (android.view.View.OnClickListener)291 Test (org.junit.Test)197 RecyclerView (android.support.v7.widget.RecyclerView)177 ScrollView (android.widget.ScrollView)157 Drawable (android.graphics.drawable.Drawable)152 DialogInterface (android.content.DialogInterface)145 Context (android.content.Context)144 EditText (android.widget.EditText)138 Bundle (android.os.Bundle)133 AlertDialog (android.app.AlertDialog)127