Example usage for android.widget TextView getText

List of usage examples for android.widget TextView getText

Introduction

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

Prototype

@ViewDebug.CapturedViewProperty
public CharSequence getText() 

Source Link

Document

Return the text that TextView is displaying.

Usage

From source file:com.applite.common.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case
            // is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }//w  ww  .  java  2  s.  co  m
            }
            if (i == selectedPosition) {
                tab.setSelected(true);
            } else {
                tab.setSelected(false);
            }
        }
    }

}

From source file:nf.frex.android.FrexActivity.java

private void preparePropertiesDialog(final Dialog dialog) {

    final Registry<Fractal> fractals = Registries.fractals;
    int fractalTypeIndex = fractals.getIndex(view.getFractalId());

    final Spinner fractalTypeSpinner = (Spinner) dialog.findViewById(R.id.fractal_type_spinner);
    final SeekBar iterationsSeekBar = (SeekBar) dialog.findViewById(R.id.num_iterations_seek_bar);
    final EditText iterationsEditText = (EditText) dialog.findViewById(R.id.num_iterations_edit_text);
    final CheckBox juliaModeCheckBox = (CheckBox) dialog.findViewById(R.id.julia_mode_fractal_check_box);
    final CheckBox decoratedFractal = (CheckBox) dialog.findViewById(R.id.decorated_fractal_check_box);
    final Button okButton = (Button) dialog.findViewById(R.id.ok_button);
    final Button cancelButton = (Button) dialog.findViewById(R.id.cancel_button);

    juliaModeCheckBox.setEnabled(true);//from   w  w  w.j a  v a2  s  .  c  o m

    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            fractals.getIds());
    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    fractalTypeSpinner.setAdapter(arrayAdapter);
    fractalTypeSpinner.setSelection(fractalTypeIndex, true);
    fractalTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View spinnerView, int position, long id) {
            Fractal fractal = fractals.getValue(position);
            iterationsEditText.setText(fractal.getDefaultIterMax() + "");
            boolean sameFractal = view.getFractalId().equals(fractals.getId(position));
            if (!sameFractal) {
                juliaModeCheckBox.setChecked(false);
            }
            juliaModeCheckBox.setEnabled(sameFractal);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    iterationsEditText.setText(view.getIterMax() + "", TextView.BufferType.NORMAL);

    final double iterationsMin = 1;
    final double iterationsMax = 3;
    final SeekBarConfigurer iterationsSeekBarConfigurer = SeekBarConfigurer.create(iterationsSeekBar,
            iterationsMin, iterationsMax, true, view.getIterMax());
    iterationsSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                int iterMax = iterationsSeekBarConfigurer.getValueInt();
                iterationsEditText.setText(iterMax + "", TextView.BufferType.NORMAL);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });

    iterationsEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            try {
                int iterMax = Integer.parseInt(v.getText().toString());
                iterationsSeekBarConfigurer.setValue(iterMax);
                return true;
            } catch (NumberFormatException e) {
                return false;
            }
        }
    });

    decoratedFractal.setChecked(view.isDecoratedFractal());

    juliaModeCheckBox.setChecked(view.isJuliaModeFractal());

    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int iterMax;
            try {
                iterMax = Integer.parseInt(iterationsEditText.getText().toString());
            } catch (NumberFormatException e) {
                Toast.makeText(FrexActivity.this, getString(R.string.error_msg, e.getLocalizedMessage()),
                        Toast.LENGTH_SHORT).show();
                return;
            }
            dialog.dismiss();
            String oldConfigName = view.getConfigName();
            String newFractalId = fractals.getId(fractalTypeSpinner.getSelectedItemPosition());
            Fractal fractal = fractals.getValue(fractalTypeSpinner.getSelectedItemPosition());
            String oldFractalId = view.getFractalId();
            boolean newJuliaModeFractal = juliaModeCheckBox.isChecked();
            boolean oldJuliaModeFractal = view.isJuliaModeFractal();
            view.setFractalId(newFractalId);
            view.setIterMax(iterMax);
            view.setDecoratedFractal(decoratedFractal.isChecked());
            view.setJuliaModeFractal(newJuliaModeFractal);
            boolean fractalTypeChanged = !oldFractalId.equals(newFractalId);
            if (fractalTypeChanged) {
                if (oldConfigName.contains(oldFractalId.toLowerCase())) {
                    view.setConfigName(newFractalId.toLowerCase());
                }
                view.setRegion(fractal.getDefaultRegion());
                view.setBailOut(fractal.getDefaultBailOut());
            }
            boolean juliaModeChanged = oldJuliaModeFractal != newJuliaModeFractal;
            if (fractalTypeChanged || juliaModeChanged) {
                view.getRegionHistory().clear();
                view.getRegionHistory().add(fractal.getDefaultRegion().clone());
            }
            view.recomputeAll();
        }
    });
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
}

From source file:com.example.Bama.widget.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_SP, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case
            // is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/*from w ww  .j  a v  a2  s. c  o m*/
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
            }
        }
    }

}

From source file:com.huiyouhui.lib.PagerSlidingTabStrip.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        //         v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }//from  w  w  w  . ja va  2 s.  c  o m
            }
        }
    }

}

From source file:com.android.app.buystoreapp.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/*from  ww  w. j  a va 2 s.  c om*/
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectedTabTextSize);
            }
        }
    }

}

From source file:cn.liucl.stationarytabstrip.PagerSlidingTabStrip.java

private void updateTabStyles(boolean isSelected, View v) {
    v.setBackgroundResource(tabBackgroundResId);

    if (v instanceof TextView) {

        TextView tab = (TextView) v;
        tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
        tab.setTypeface(tabTypeface, tabTypefaceStyle);
        tab.setTextColor(tabTextColor);/*from   w  w w  . ja  va2s .  c  o  m*/

        // setAllCaps() is only available from API 14, so the upper case
        // is made manually if we are on a
        // pre-ICS-build
        if (textAllCaps) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                tab.setAllCaps(true);
            } else {
                tab.setText(tab.getText().toString().toUpperCase(locale));
            }
        }
        if (isSelected) {
            tab.setTextColor(selectedTabTextColor);
        }
    }
}

From source file:com.astuetz.PagerSlidingTabStripExtend.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/*from w  ww  .j ava 2  s  .co m*/
            }

            //??
            if (i == mSelectedIndex) {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabSelectedTextSize);
                tab.setTextColor(tabSelectedTextColor);
            }
        }
    }

}

From source file:com.example.contactslist.ui.ContactsListFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    // Gets the Cursor object currently bound to the ListView
    final Cursor cursor = mAdapter.getCursor();
    TextView artistInfoView = (TextView) v.findViewById(R.id.artistInfo);
    String artistinfo = artistInfoView.getText().toString();
    TextView trackInfoView = (TextView) v.findViewById(R.id.trackInfo);
    String trackinfo = trackInfoView.getText().toString();
    StringAppService.get(getActivity()).playBroadcastedSong(getActivity(), artistinfo, trackinfo);
    // Moves to the Cursor row corresponding to the ListView item that was clicked
    cursor.moveToPosition(position);/*from  w ww .j  av  a  2 s  .co  m*/

    // Creates a contact lookup Uri from contact ID and lookup_key
    final Uri uri = Contacts.getLookupUri(cursor.getLong(ContactsQuery.ID),
            cursor.getString(ContactsQuery.LOOKUP_KEY));

    // Notifies the parent activity that the user selected a contact. In a two-pane layout, the
    // parent activity loads a ContactDetailFragment that displays the details for the selected
    // contact. In a single-pane layout, the parent activity starts a new activity that
    // displays contact details in its own Fragment.
    mOnContactSelectedListener.onContactSelected(uri);

    // If two-pane layout sets the selected item to checked so it remains highlighted. In a
    // single-pane layout a new activity is started so this is not needed.
    if (mIsTwoPaneLayout) {
        getListView().setItemChecked(position, true);
    }
}

From source file:com.astuetz.PagerSlidingTabStripCopy.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }//from   w  w  w  .  j a va 2  s  .c om

            }
            if (mCurrent == i) {
                tab.setTextSize(mTitleSelectedSize);
                tab.setTypeface(tabTypeface, tabTypefaceStyle);
                tab.setTextColor(mTitleSelectedColor);
            }
        }
    }

}

From source file:com.astuetz.PagerSlidingTabStripExpand.java

/**
 *  ?//from ww  w.java  2  s  .c  om
 */
private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }

            //? ??
            if (mCurrentSelectedIndex == i) {
                tab.setTextColor(tabSelectedTextColor);
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabSelectedTextSize);
            }
        }
    }

}