private void initSwitchers() { temperatureSwitcher = (TextSwitcher) findViewById(R.id.cs_ts_temperature); temperatureSwitcher.setFactory(new TextViewFactory(R.style.CsTemperatureTextView, true)); temperatureSwitcher.setCurrentText(temperatures[0]); placeSwitcher = (TextSwitcher) findViewById(R.id.cs_ts_place); placeSwitcher.setFactory(new TextViewFactory(R.style.CsPlaceTextView, false)); placeSwitcher.setCurrentText(places[0]); clockSwitcher = (TextSwitcher) findViewById(R.id.cs_ts_clock); clockSwitcher.setFactory(new TextViewFactory(R.style.CsClockTextView, false)); clockSwitcher.setCurrentText(times[0]); descriptionsSwitcher = (TextSwitcher) findViewById(R.id.cs_ts_description); descriptionsSwitcher.setInAnimation(this, android.R.anim.fade_in); descriptionsSwitcher.setOutAnimation(this, android.R.anim.fade_out); descriptionsSwitcher.setFactory(new TextViewFactory(R.style.CsDescriptionTextView, false)); descriptionsSwitcher.setCurrentText(getString(descriptions[0])); mapSwitcher = (ImageSwitcher) findViewById(R.id.cs_ts_map); mapSwitcher.setInAnimation(this, R.anim.cs_fade_in); mapSwitcher.setOutAnimation(this, R.anim.cs_fade_out); mapSwitcher.setFactory(new ImageViewFactory()); mapSwitcher.setImageResource(maps[0]); }
private void init(Context context) { textSwitcher = new TextSwitcher(context); textSwitcher.addView(createViewForTextSwitcher(context)); textSwitcher.addView(createViewForTextSwitcher(context)); addView(textSwitcher, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView = new TextView(context); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { textView.setTextAppearance(R.style.EcPositionIndicator); } else { textView.setTextAppearance(context, R.style.EcPositionIndicator); } addView(textView, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); }
public void initViews() { tvPlayProgress = (TextView) activity.findViewById(R.id.play_progress); tvDuration = (TextView) activity.findViewById(R.id.play_duration); sbSongProgress = (DiscreteSeekBar) activity.findViewById(R.id.play_seekBar); tsSongName = (TextSwitcher) activity.findViewById(R.id.play_ts_song_name); tsSongArts = (TextSwitcher) activity.findViewById(R.id.play_ts_song_arts); btPre = (SkipView) activity.findViewById(R.id.play_pre_song); btNext = (SkipView) activity.findViewById(R.id.play_next_song); btPlay = (PlayView) activity.findViewById(R.id.play_song); btPre.setOnClickListener(this); btNext.setOnClickListener(this); btPlay.setOnClickListener(this); }
@Override public View onCreateView( final LayoutInflater inflater, final @Nullable ViewGroup container, final @Nullable Bundle savedInstanceState) { final View picker = inflater.inflate(R.layout.fragment_category_picker, container, false); categories = (RadioGroup) picker.findViewById(R.id.categories); categoryLabel = (TextSwitcher) picker.findViewById(R.id.selected_category); categories.setOnCheckedChangeListener(new IconPickerWrapper(categoryLabel)); categories.check(R.id.other); return picker; }
private void setupPassageSection(Devotional dev, View view) { TextView verses = (TextView) view.findViewById(R.id.dev_passage_verses); verses.setText(dev.getPassages()); this.passages = passageDb.readPassages(dev.getGuid()); passageContent = (TextSwitcher) view.findViewById(R.id.dev_passage_content); passageContent.setFactory(new ViewSwitcher.ViewFactory() { public View makeView() { TextView myText = new TextView(ShowDevotionalActivity.this); return myText; } }); Animation in = AnimationUtils.loadAnimation(this, android.R.anim.fade_in); passageContent.setInAnimation(in); Spinner transSelector = (Spinner) view.findViewById(R.id.dev_passage_translation_selector); ArrayAdapter<Translation> transSelAdapter = new ArrayAdapter<>(this, android.R.layout .simple_spinner_item, Translation.values()); transSelAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); transSelector.setAdapter(transSelAdapter); transSelector.setOnItemSelectedListener(this); }
private void spinAllSwitchers() { // deal with digits digits[0].setText(DIGITS[random.nextInt(10)]); int multiplier = 1; for (int i = 1; i < digits.length; i++) { if (digits[i].getVisibility() == GONE) { // reached the end, quit break; } multiplier *= 10; if ((value * multiplier) > (multiplier - 1)) { digits[i].setText(DIGITS[random.nextInt(10)]); } } if (value % 1 > 0 || forceDedimal) { for (final TextSwitcher decimal : decimals) { decimal.setText(DIGITS[random.nextInt(10)]); } } }
private void initializeTextSwitcher(@NonNull final Context context) { selectedTextView = new TextSwitcher(getContext()); selectedTextView.setFactory(this); selectedTextView.setAnimateFirstView(false); selectedTextView.setBackgroundResource(mSelectedTextBackground); if (mTextSwitcherInAnimation != 0) { selectedTextView.setInAnimation(context, mTextSwitcherInAnimation); } if (mTextSwitcherOutAnimation != 0) { selectedTextView.setOutAnimation(context, mTextSwitcherOutAnimation); } LayoutParams params = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT); params.gravity = Gravity.CENTER; selectedTextView.setLayoutParams(params); selectedTextView.setLayerType(LAYER_TYPE_HARDWARE, null); addView(selectedTextView); }
private void generateDialogContent(){ this.dialog = new Dialog((BaseActivityAbstract)this.getActivity()); this.dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); this.dialog.setContentView(R.layout.summary_result_dialog_layout); this.dialog.setCancelable(false); this.tryAgainDialogButton = (Button)dialog.findViewById(R.id.summary_dialog_retry_button); this.quitDialogButton = (Button)dialog.findViewById(R.id.summary_dialog_quit_button); final SummaryDialogDisplayTaskImpl currentSummaryDialogDisplayTaskImpl = this; this.earnedPointTextSwitcher = (TextSwitcher) this.dialog.findViewById(R.id.summary_point_textswitcher); final int textColorInt = Color.parseColor("#41A62A"); this.earnedPointTextSwitcher.setFactory(new ViewFactory() { public View makeView() { TextView textView = new TextView(currentSummaryDialogDisplayTaskImpl.getActivity().getApplicationContext()); textView.setGravity(Gravity.LEFT); textView.setTextColor(textColorInt); return textView; } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.text_switcher_1); mSwitcher = (TextSwitcher) findViewById(R.id.switcher); mSwitcher.setFactory(this); Animation in = AnimationUtils.loadAnimation(this, android.R.anim.fade_in); Animation out = AnimationUtils.loadAnimation(this, android.R.anim.fade_out); mSwitcher.setInAnimation(in); mSwitcher.setOutAnimation(out); Button nextButton = (Button) findViewById(R.id.next); nextButton.setOnClickListener(this); updateCounter(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); textview = (TextView) findViewById(R.id.textview); // ���TextSwitch�����ã� mTextSwitcher = (TextSwitcher) findViewById(R.id.your_textview); //ָ��TextSwitcher��viewFactory mTextSwitcher.setFactory(new ViewFactory() { @Override public View makeView() { TextView t = new TextView(MainActivity.this); t.setGravity(Gravity.CENTER); return t; } }); // �������붯��Ч��,ʹ��ϵͳ��̸��Ч����Ҳ�����Զ��� mTextSwitcher.setInAnimation(this, android.R.anim.fade_in); // �����г�����Ч����ʹ��ϵͳ��̸��Ч����Ҳ�����Զ��� mTextSwitcher.setOutAnimation(this, android.R.anim.fade_out); onSwitchText(null); }
@Override public void setText(CharSequence text, boolean animate) { View view = getView(); if (view == null) { return; } TextSwitcher textSwitcher = (TextSwitcher) view; if (animate) { textSwitcher.setText(text); } else { TextView curr = (TextView) textSwitcher.getCurrentView(); curr.setText(text); } // // waiting for the first layout of SWITCHER to be finished, // so that we can adjust its size according to its content. // // 100 ms // schedule(MSG_TEXT_VIEW_ADJUST_HEIGHT, 100); }
private void updateAnimation() { View view = getView(); if (view == null) { return; } ViewSwitcher viewSwitcher = (ViewSwitcher) view; if (viewSwitcher.getInAnimation() != mInAnimation || mInAnimation == null) { if (mInAnimation == null) { mInAnimation = AnimationFactory.pushDownIn(); } if (viewSwitcher instanceof TextSwitcher) { mInAnimation.setAnimationListener(mTextViewInAnimationListener); } mInAnimation.setDuration(mInDuration); viewSwitcher.setInAnimation(mInAnimation); } if (viewSwitcher.getOutAnimation() != mOutAnimation || mOutAnimation == null) { if (mOutAnimation == null) { mOutAnimation = AnimationFactory.pushDownOut(); } mOutAnimation.setDuration(mOutDuration); viewSwitcher.setOutAnimation(mOutAnimation); } }
private void adjustTextViewHeight() { View view = getView(); if (view == null) { return; } TextSwitcher textSwitcher = (TextSwitcher) view; TextView curr = (TextView) textSwitcher.getCurrentView(); TextView next = (TextView) textSwitcher.getNextView(); int currH = curr.getLineCount() * curr.getLineHeight(); int nextH = next.getLineCount() * next.getLineHeight(); if (currH != nextH) { curr.setHeight(currH); next.setHeight(currH); } }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mListAdapter = new ConversionRateListAdapter(getActivity(), null, 0); setListAdapter(mListAdapter); View rootView = inflater.inflate(R.layout.fragment_currencies, container, false); Button updateButton = (Button) rootView.findViewById(R.id.button_update_conversion_rates); updateButton.setOnClickListener(this); final Context context = getActivity(); TextSwitcher updateText = (TextSwitcher) rootView.findViewById(R.id.textswitcher_update_conversion_rates); Animation in = AnimationUtils.loadAnimation(context, android.R.anim.fade_in); Animation out = AnimationUtils.loadAnimation(context, android.R.anim.fade_out); updateText.setInAnimation(in); updateText.setOutAnimation(out); updateText.setFactory(() -> { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); return textView; }); return rootView; }
@Override public void onConversionRatesUpdated(List<ConversionRate> conversionRates) { View rootView = getView(); if (rootView == null) { Log.e(LOG_TAG, "rootView was null in onConversionRatesUpdated"); return; } // Find updated rate of currently selected conversion rate ListView listView = getListView(); Cursor cursor = (Cursor) listView.getItemAtPosition(listView.getCheckedItemPosition()); ConversionRate selectedConversionRate = ConverterDbHelper.conversionRateFromCursor(cursor); ConversionRate updatedConversionRate = conversionRates.get(conversionRates.indexOf(selectedConversionRate)); // Store updated rate and notify the Convert tab about it Settings.writeConversionRate(getActivity(), updatedConversionRate); mListener.onConversionRatesUpdated(); // Enable update button and set status text Button updateButton = (Button) rootView.findViewById(R.id.button_update_conversion_rates); updateButton.setEnabled(true); TextSwitcher statusText = (TextSwitcher) rootView.findViewById(R.id.textswitcher_update_conversion_rates); statusText.setText(getString(R.string.updated)); clearUpdateStatusAfterDelay(statusText); }
private void initTextSwitcher() { mTextSwitcher = (TextSwitcher) findViewById(R.id.tv_switcher); Animation in = AnimationUtils.loadAnimation(this, android.R.anim.fade_in); Animation out = AnimationUtils.loadAnimation(this,android.R.anim.fade_out); mTextSwitcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { TextView tv = new TextView(TextAndImageAnimation.this); tv.setGravity(Gravity.CENTER); return tv; } }); mTextSwitcher.setInAnimation(in); mTextSwitcher.setOutAnimation(out); mTextChangeRunnable = new ChangeTextRunnable(); }
@Override protected void setUp() throws Exception { super.setUp(); mActivity = this.getActivity(); startText = (TextView) mActivity.findViewById(R.id.start); endText = (TextView) mActivity.findViewById(R.id.end); nextTime = (TextSwitcher) mActivity.findViewById(R.id.next_time); nextRoute = (TextView) mActivity.findViewById(R.id.next_route); nextBus = (TextView) mActivity.findViewById(R.id.next_bus); callSafeRideButton = (TextView) mActivity.findViewById(R.id.safe_ride_button); drawer = (MultipleOrientationSlidingDrawer) mActivity.findViewById(R.id.sliding_drawer); startTextCorrect = mActivity.getString(R.string.start); safeRideTextCorrect = mActivity.getString(R.string.call_safe_ride); endTextCorrect = mActivity.getString(R.string.end); decorView = mActivity.getWindow().getDecorView(); }
private TextView createViewForTextSwitcher(Context context) { TextView textView = new TextView(context); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { textView.setTextAppearance(R.style.EcPositionIndicatorCurrent); } else { textView.setTextAppearance(context, R.style.EcPositionIndicatorCurrent); } textView.setLayoutParams(new TextSwitcher.LayoutParams(TextSwitcher.LayoutParams.WRAP_CONTENT, TextSwitcher.LayoutParams.WRAP_CONTENT)); return textView; }
CellFeedViewHolder(View view) { super(view); ivFeedCenter = (ImageView) view.findViewById(R.id.ivFeedCenter); ivFeedBottom = (ImageView) view.findViewById(R.id.ivFeedBottom); btnComments = (ImageButton) view.findViewById(R.id.btnComments); btnLike = (ImageButton) view.findViewById(R.id.btnLike); btnMore = (ImageButton) view.findViewById(R.id.btnMore); tsLikesCounter = (TextSwitcher) view.findViewById(R.id.tsLikesCounter); ivUserProfile = (ImageView) view.findViewById(R.id.ivUserProfile); vImageRoot = (FrameLayout) view.findViewById(R.id.vImageRoot); }
public static TextWrapper<TextSwitcher> wrap(final TextSwitcher ts) { return new TextWrapper<TextSwitcher>(ts) { @Override public void setText(final CharSequence text) { view.setText(text); } @Override public CharSequence getText() { return ((TextView) view.getCurrentView()).getText(); } }; }
public static TextWrapper<?> wrap(final View v) { if (v instanceof TextView) { return wrap((TextView) v); } else if (v instanceof TextSwitcher) { return wrap((TextSwitcher) v); } else { throw new IllegalArgumentException("unknown text view: " + v); } }
private void initSwitchers() { temperatureSwitcher = (TextSwitcher) findViewById(R.id.ts_temperature); temperatureSwitcher.setFactory(new TextViewFactory(R.style.TemperatureTextView, true)); temperatureSwitcher.setCurrentText(temperatures[0]); placeSwitcher = (TextSwitcher) findViewById(R.id.ts_place); placeSwitcher.setFactory(new TextViewFactory(R.style.PlaceTextView, false)); placeSwitcher.setCurrentText(places[0]); clockSwitcher = (TextSwitcher) findViewById(R.id.ts_clock); clockSwitcher.setFactory(new TextViewFactory(R.style.ClockTextView, false)); clockSwitcher.setCurrentText(times[0]); descriptionsSwitcher = (TextSwitcher) findViewById(R.id.ts_description); descriptionsSwitcher.setInAnimation(this, android.R.anim.fade_in); descriptionsSwitcher.setOutAnimation(this, android.R.anim.fade_out); descriptionsSwitcher.setFactory(new TextViewFactory(R.style.DescriptionTextView, false)); descriptionsSwitcher.setCurrentText(getString(descriptions[0])); mapSwitcher = (ImageSwitcher) findViewById(R.id.ts_map); mapSwitcher.setInAnimation(this, R.anim.fade_in); mapSwitcher.setOutAnimation(this, R.anim.fade_out); mapSwitcher.setFactory(new ImageViewFactory()); mapSwitcher.setImageResource(maps[0]); mapLoadListener = new DecodeBitmapTask.Listener() { @Override public void onPostExecuted(Bitmap bitmap) { ((ImageView)mapSwitcher.getNextView()).setImageBitmap(bitmap); mapSwitcher.showNext(); } }; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); hintTextView = (TextSwitcher) findViewById(R.id.hint_text_view); custodeView = (CustodeButtonView) findViewById(R.id.button_view); custodeView.setOnTouchListener(this); onTouchUpRunnable = new Runnable() { @Override public void run() { Intent myIntent = new Intent(MainActivity.this, PinCountdownActivity.class); startActivity(myIntent); overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left); } }; onTouchDownRunnable = new Runnable() { @Override public void run() { CustodeUtils.setScreenBrightness(MainActivity.this, WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF); Intent i = new Intent(MainActivity.this, LocationService.class); i.setAction(LocationService.GEOCODE_OFF_ACTION); startService(i); } }; vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSendText = (EditText) findViewById(R.id.main_text_input); mRecvText = (TextSwitcher) findViewById(R.id.main_text_recv); }
public CardViewHolder(CardView itemView) { super(itemView); chartView = (ChartView) itemView.findViewById(R.id.chart_view); sensorSelectionArea = itemView.findViewById(R.id.sensor_selection_area); sensorTabLayout = (TabLayout) itemView.findViewById(R.id.sensor_selector_tab_layout); sensorSettingsGear = (ImageButton) itemView.findViewById(R.id.settings_gear); sensorTabHolder = (ViewGroup) itemView.findViewById(R.id.sensor_selection_tab_holder); graphStatsList = (StatsList) itemView.findViewById(R.id.stats_drawer); header = (SensorCardHeader) itemView.findViewById(R.id.sensor_card_header); headerText = (TextView) itemView.findViewById(R.id.sensor_card_header_title); toggleButton = (ToggleArrow) itemView.findViewById(R.id.btn_sensor_card_toggle); toggleButtonSpacer = itemView.findViewById(R.id.sensor_card_toggle_spacer); menuButton = (ImageButton) itemView.findViewById(R.id.btn_sensor_card_overflow_menu); graphViewGroup = (ViewGroup) itemView.findViewById(R.id.graph_view_content_group); meterSensorIcon = (ImageView) itemView.findViewById(R.id.card_meter_sensor_icon); meterLiveData = (SingleLineResizableTextView) itemView.findViewById(R.id.live_sensor_value); statusViewGroup = (ViewGroup) itemView.findViewById(R.id.status_view_content_group); statusProgressBar = (ProgressBar) itemView.findViewById(R.id.progress_bar); statusMessage = (TextView) itemView.findViewById(R.id.status_message); statusRetryButton = (Button) itemView.findViewById(R.id.status_retry_button); triggerSection = (RelativeLayout) itemView.findViewById(R.id.sensor_card_trigger_section); triggerIcon = (ViewSwitcher) itemView.findViewById(R.id.trigger_icon_view_switcher); triggerLevelDrawableButton = (ImageButton) itemView.findViewById(R.id.sensor_trigger_icon); triggerTextSwitcher = (TextSwitcher) itemView.findViewById(R.id.trigger_text_switcher); triggerFiredBackground = (TriggerBackgroundView) itemView.findViewById( R.id.sensor_trigger_fired_background); triggerFiredText = (TextView) itemView.findViewById(R.id.trigger_fired_text); infoButton = (ImageButton) itemView.findViewById(R.id.btn_info); WindowManager windowManager = (WindowManager) itemView.getContext().getSystemService(Context.WINDOW_SERVICE); screenOrientation = windowManager.getDefaultDisplay().getRotation(); }
@Override protected void onFinishInflate() { super.onFinishInflate(); modifierTitle = (TextView) findViewById(R.id.bike_image_modifier_title); textSwitcher = (TextSwitcher) findViewById(R.id.text_switcher); textSwitcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { return LayoutInflater.from(getContext()).inflate(R.layout.modifier_value_textview, null); } }); }
private void setupTextSwitcher(TextSwitcher textSwitcher) { textSwitcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { TextView textView = new TextView(getContext()); textView.setTextSize(textSize); textView.setTextColor(textColor); return textView; } }); textSwitcher.setInAnimation(getInAnimation()); textSwitcher.setOutAnimation(getContext(), slideOutAnimation); }
private void setupDigitsVisibility() { for (TextSwitcher ts : digits) { ts.setVisibility(VISIBLE); } int zeroIndex = -1; for (int i = digNums.length - 1; i >= 0; i--) { if (digNums[i] != 0) { break; } zeroIndex = i; } if (zeroIndex == -1) { // they all have sig digits return; } if (zeroIndex == 0) { // all zeros, hide all minus last for (int i = 1; i < digits.length; i++) { digits[i].setVisibility(GONE); } return; } for (int i = zeroIndex; i < digits.length; i++) { digits[i].setVisibility(GONE); } }
@Override public void jmResultsCallback(List<EntryOptimized> results, SearchInfo search) { StringBuilder sb = new StringBuilder(); for (EntryOptimized eo : results){ sb.append(eo.getKanji()); if (!eo.getReadings().isEmpty()){ sb.append(" ("); sb.append(eo.getReadings()); sb.append(")"); } sb.append("\n"); sb.append(eo.getMeanings()); sb.append("\n\n"); } if (sb.length() > 2){ sb.setLength(sb.length() - 1); } TextSwitcher tv = (TextSwitcher) mLinearLayout.findViewById(R.id.jm_results); tv.setText(sb.toString()); int start = mKanjiGrid.getKanjiViewList().indexOf(search.getKanjiCharacterView()); if (results.size() > 0){ String kanji = results.get(0).getKanji(); for (int i = start; i < start + kanji.codePointCount(0, kanji.length()); i++){ mKanjiGrid.getKanjiViewList().get(i).setBackground(); } } else { mKanjiGrid.getKanjiViewList().get(start).setBackground(); } }