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:cn.qbcbyb.library.view.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;
            if (i == currentItem) {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabSelectedTextSize);
            } else {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            }/*from  w ww.j  a v a2s . c om*/
            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 source file:com.androguide.honamicontrol.kernel.cpucontrol.CPUActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //noinspection ConstantConditions
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setIcon(getResources().getDrawable(R.drawable.ic_tools_cpu_control));
    setContentView(R.layout.card_cpu_control);
    bootPrefs = getSharedPreferences("BOOT_PREFS", 0);

    graph = (LineGraph) findViewById(R.id.graph);
    line = new Line();
    LinePoint point = new LinePoint();
    point.setX(currX);/*  w ww. j  a v  a 2 s  .  com*/
    point.setY(1);
    line.addPoint(point);
    line.setColor(Color.parseColor("#FFBB33"));
    graph.addLine(line);
    graph.setLineToFill(0);

    availableFrequencies = new String[0];
    String availableFrequenciesLine;

    mCoresOnline = (TextView) findViewById(R.id.cores_online);
    mGeneralGovernor = (Spinner) findViewById(R.id.general_governor);
    mGovernor = (Spinner) findViewById(R.id.governor);
    mGovernor2 = (Spinner) findViewById(R.id.governor2);
    mGovernor3 = (Spinner) findViewById(R.id.governor3);
    mGovernor4 = (Spinner) findViewById(R.id.governor4);

    Button customizeGov = (Button) findViewById(R.id.governor_customize_btn);
    customizeGov.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            FragmentManager fm = getSupportFragmentManager();
            GovernorDialog editNameDialog = new GovernorDialog();
            editNameDialog.show(fm, "governor_fragment");
        }
    });

    if (Helpers.doesFileExist(STEPS)) {
        availableFrequenciesLine = CPUHelper.readOneLineNotRoot(STEPS);

        if (availableFrequenciesLine != null) {
            availableFrequencies = availableFrequenciesLine.split(" ");
            Arrays.sort(availableFrequencies, new Comparator<String>() {
                @Override
                public int compare(String object1, String object2) {
                    return Integer.valueOf(object1).compareTo(Integer.valueOf(object2));
                }
            });
        }
    }

    Switch snakeCharmer = (Switch) findViewById(R.id.snake_charmer_switch);
    if (!Helpers.doesFileExist(SNAKE_CHARMER_MAX_FREQ)) {
        LinearLayout cardSnakeCharmer = (LinearLayout) findViewById(R.id.card_snake_charmer);
        cardSnakeCharmer.setVisibility(View.GONE);
    } else {
        if (Helpers.doesFileExist(SNAKE_CHARMER_VERSION)) {
            TextView snakeTitle = (TextView) findViewById(R.id.snake_charmer);
            String snakeVersion = CPUHelper.readOneLineNotRoot(SNAKE_CHARMER_VERSION);
            snakeVersion = snakeVersion.replaceAll("version: ", "v");
            snakeTitle.setText(snakeTitle.getText() + " " + snakeVersion);
            if (snakeVersion.equals("v1.2")) {
                TextView snakeDesc = (TextView) findViewById(R.id.snake_charmer_text);
                snakeDesc.setText(snakeDesc.getText() + "\n" + getString(R.string.snake_charmer_built_in));
                snakeCharmer.setEnabled(false);
            }
        }

        if (bootPrefs.getBoolean("SNAKE_CHARMER", true)) {
            snakeCharmer.setChecked(true);
            snakeCharmerEnabled = true;
        }

        snakeCharmer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean isOn) {
                snakeCharmerEnabled = isOn;
            }
        });
    }

    int frequenciesNum = availableFrequencies.length - 1;

    Switch thermalControl = (Switch) findViewById(R.id.msm_thermal_switch);
    if (Helpers.doesFileExist(MSM_THERMAL)) {
        String thermal = CPUHelper.readOneLineNotRoot(MSM_THERMAL);
        if (thermal.equals("Y"))
            thermalControl.setChecked(true);
        else
            thermalControl.setChecked(false);

        thermalControl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
                if (isChecked)
                    Helpers.CMDProcessorWrapper.runSuCommand("echo Y > " + MSM_THERMAL);
                else
                    Helpers.CMDProcessorWrapper.runSuCommand("echo N > " + MSM_THERMAL);

                bootPrefs.edit().putBoolean("MSM_THERMAL", isChecked).commit();
            }
        });
    }
    thermalControl.setChecked(bootPrefs.getBoolean("MSM_THERMAL", true));

    perCoreGovernor = (Switch) findViewById(R.id.per_core_governors_switch);
    perCoreGovernor.setChecked(bootPrefs.getBoolean("PER_CORE_GOV", true));

    if (perCoreGovernor.isChecked()) {
        findViewById(R.id.card_general_governor).setVisibility(View.GONE);
        findViewById(R.id.card_per_core_governors).setVisibility(View.VISIBLE);
    } else {
        findViewById(R.id.card_per_core_governors).setVisibility(View.GONE);
        findViewById(R.id.card_general_governor).setVisibility(View.VISIBLE);
    }

    perCoreGovernor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            if (isChecked) {
                findViewById(R.id.card_general_governor).setVisibility(View.GONE);
                findViewById(R.id.card_per_core_governors).setVisibility(View.VISIBLE);
                handleGovernors();
            } else {
                findViewById(R.id.card_per_core_governors).setVisibility(View.GONE);
                findViewById(R.id.card_general_governor).setVisibility(View.VISIBLE);
                handleGovernors();
            }

            bootPrefs.edit().putBoolean("PER_CORE_GOV", isChecked).commit();
        }
    });

    String currentIo = "";
    if (Helpers.doesFileExist(IO_SCHEDULER))
        currentIo = CPUHelper.getIOScheduler();

    String currentTcp = "";
    if (Helpers.doesFileExist(CURR_TCP_ALGORITHM))
        currentTcp = Helpers.getCurrentTcpAlgorithm();

    String curMaxSpeed = "NaN";
    if (Helpers.doesFileExist(MAX_FREQ_ALL_CORES))
        curMaxSpeed = CPUHelper.readOneLineNotRoot(MAX_FREQ_ALL_CORES);
    else if (Helpers.doesFileExist(MAX_FREQ))
        curMaxSpeed = CPUHelper.readOneLineNotRoot(MAX_FREQ);

    String curMinSpeed = "NaN";
    if (Helpers.doesFileExist(MIN_FREQ_ALL_CORES))
        curMinSpeed = CPUHelper.readOneLineNotRoot(MIN_FREQ_ALL_CORES);
    else if (Helpers.doesFileExist(MIN_FREQ))
        curMinSpeed = CPUHelper.readOneLineNotRoot(MIN_FREQ);

    if (mIsTegra3) {
        String curTegraMaxSpeed = "NaN";
        if (Helpers.doesFileExist(TEGRA_MAX_FREQ)) {
            curTegraMaxSpeed = CPUHelper.readOneLineNotRoot(TEGRA_MAX_FREQ);
            int curTegraMax = 0;
            try {
                curTegraMax = Integer.parseInt(curTegraMaxSpeed);
                if (curTegraMax > 0) {
                    curMaxSpeed = Integer.toString(curTegraMax);
                }
            } catch (NumberFormatException ex) {
                curTegraMax = 0;
            }
        }
    }

    if (Helpers.doesFileExist(NUM_OF_CPUS))
        mNumOfCpus = Helpers.getNumOfCpus();

    mCurFreq = (TextView) findViewById(R.id.currspeed);

    mMaxSlider = (SeekBar) findViewById(R.id.max_slider);
    mMaxSlider.setMax(frequenciesNum);
    mMaxSpeedText = (TextView) findViewById(R.id.max_speed_text);
    mMaxSpeedText.setText(toMHz(curMaxSpeed));
    mMaxSlider.setProgress(Arrays.asList(availableFrequencies).indexOf(curMaxSpeed));
    mMaxSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser)
                setMaxSpeed(seekBar, progress);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            startSupportActionMode(new ActionMode.Callback() {
                @Override
                public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
                    MenuInflater inflater = actionMode.getMenuInflater();
                    inflater.inflate(R.menu.contextual_menu, menu);
                    return true;
                }

                @Override
                public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
                    return false;
                }

                @Override
                public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
                    switch (menuItem.getItemId()) {
                    case R.id.apply:
                        if (mMaxFreqSetting != null && !mMaxFreqSetting.isEmpty()) {
                            bootPrefs.edit().putString("CPU_MAX_FREQ", mMaxFreqSetting).commit();
                            for (int i = 0; i < mNumOfCpus; i++)
                                Helpers.CMDProcessorWrapper.runSuCommand("busybox echo " + mMaxFreqSetting
                                        + " > " + MAX_FREQ.replace("cpu0", "cpu" + i));

                            if (snakeCharmerEnabled)
                                Helpers.CMDProcessorWrapper.runSuCommand(
                                        "busybox echo " + mMaxFreqSetting + " > " + SNAKE_CHARMER_MAX_FREQ);
                        }

                        if (mIsTegra3) {
                            if (mMaxFreqSetting != null && !mMaxFreqSetting.isEmpty())
                                Helpers.CMDProcessorWrapper.runSuCommand(
                                        "busybox echo " + mMaxFreqSetting + " > " + TEGRA_MAX_FREQ);

                            if (snakeCharmerEnabled)
                                Helpers.CMDProcessorWrapper.runSuCommand(
                                        "busybox echo " + mMaxFreqSetting + " > " + SNAKE_CHARMER_MAX_FREQ);
                        }
                        actionMode.finish();
                        return true;
                    default:
                        return false;
                    }
                }

                @Override
                public void onDestroyActionMode(ActionMode actionMode) {

                }
            });
        }
    });

    mMinSlider = (SeekBar) findViewById(R.id.min_slider);
    mMinSlider.setMax(frequenciesNum);
    mMinSpeedText = (TextView) findViewById(R.id.min_speed_text);
    mMinSpeedText.setText(toMHz(curMinSpeed));
    mMinSlider.setProgress(Arrays.asList(availableFrequencies).indexOf(curMinSpeed));
    mMinSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser)
                setMinSpeed(seekBar, progress);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            startSupportActionMode(new ActionMode.Callback() {
                @Override
                public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
                    MenuInflater inflater = actionMode.getMenuInflater();
                    inflater.inflate(R.menu.contextual_menu, menu);
                    return true;
                }

                @Override
                public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
                    return false;
                }

                @Override
                public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
                    switch (menuItem.getItemId()) {
                    case R.id.apply:
                        if (mMinFreqSetting != null && !mMinFreqSetting.isEmpty()) {
                            bootPrefs.edit().putString("CPU_MIN_FREQ", mMinFreqSetting).commit();
                            for (int i = 0; i < mNumOfCpus; i++)
                                Helpers.CMDProcessorWrapper.runSuCommand("busybox echo " + mMinFreqSetting
                                        + " > " + MIN_FREQ.replace("cpu0", "cpu" + i));
                        }
                        actionMode.finish();
                        return true;
                    default:
                        return false;
                    }
                }

                @Override
                public void onDestroyActionMode(ActionMode actionMode) {

                }
            });
        }
    });

    handleGovernors();

    /** TCP Congestion Spinner */
    Spinner mTcp = (Spinner) findViewById(R.id.tcp);
    ArrayAdapter<CharSequence> tcpAdapter = new ArrayAdapter<CharSequence>(this, R.layout.spinner_row);
    tcpAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    ArrayList<String> algorithms = Helpers.getTcpAlgorithms();
    for (String algorithm : algorithms)
        tcpAdapter.add(algorithm);
    mTcp.setAdapter(tcpAdapter);
    mTcp.setSelection(algorithms.indexOf(currentTcp));
    mTcp.setOnItemSelectedListener(new TCPListener());

    onlineCoresPolling();
}

From source file:com.astuetz.PagerSlidingTabStripCustom.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, textSize);//TODO
            //            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            //                tab.setTextColor(tabTextColor);
            tab.setTextColor(textColor);//TODO

            // 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));
                }/*ww  w  .j a  v a  2s.  com*/
            }
            //TODO  ?pageTitle?
            if (mCurrentPosition == i) {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectTextSize);
                tab.setTextColor(selectTextColor);
            }
        }
    }

}

From source file:com.dashihui.afford.ui.widget.WdtPagerTabServerTime.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);
            /*****************/
            //            tab.setBackgroundResource(R.drawable.servicetime_btn_label_bottom);

            // 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.  java 2s .  c o m*/
            }
        }
    }

}

From source file:cn.com.pplo.sicauhelper.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_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            //tab
            if (i == 0) {
                tab.setTextColor(Color.parseColor("#ffffff"));
            } else {
                tab.setTextColor(tabTextColor);
            }//from w  w  w.  java 2  s  .  com

            // 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 source file:com.baseutil.strip.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);
            if (tabResources != null) {
                tab.setCompoundDrawablesWithIntrinsicBounds(tabResources[i], 0, 0, 0);
            }/*  w  ww . ja v a 2  s .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));
                }
            }
        }
    }

}

From source file:at.alladin.rmbt.android.main.RMBTMainMenuFragment.java

public void setViewText(TextView view, String text, TextView alternativeView) {
    if (view != null) {
        view.setText(text);//from  w  w w  . j ava  2s.  co  m
    } else if (alternativeView != null) {
        alternativeView.setText(alternativeView.getText() + " " + text);
    }
}

From source file:com.example.wechatsample.utils.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_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);
            //?tab
            tab.setBackgroundResource(R.drawable.background_tab);
            //            tab.setTextColor(R.drawable.tabtextcolor_selector);

            // 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  av a  2  s.  c  o m*/
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
                tab.setBackgroundResource(0);
            }
        }
    }

}

From source file:com.example.linkagescroll.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_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            if (i == currentPosition) {
                tab.setTextColor(tabTextSelectColor);
            } else {
                tab.setTextColor(tabTextColor);
            }//  w ww .  ja  v a  2  s .  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));
                }
            }
        }
    }

}

From source file:com.gh4a.IssueLabelListActivity.java

private void selectLabel(TextView tvLabel, View viewColor, String color, boolean clearOtherSelected,
        EditText etLabel) {//from ww  w  .  ja v  a 2s .c  om
    final Typeface boldCondensed = getApplicationContext().boldCondensed;
    tvLabel.setTag(color);

    viewColor.setBackgroundColor(Color.parseColor("#" + color));
    tvLabel.setBackgroundColor(Color.parseColor("#" + color));
    int r = Color.red(Color.parseColor("#" + color));
    int g = Color.green(Color.parseColor("#" + color));
    int b = Color.blue(Color.parseColor("#" + color));
    if (r + g + b < 383) {
        tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_dark));
    } else {
        tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light));
    }
    tvLabel.setTypeface(boldCondensed);

    mSelectedColor = color;
    mSelectedEtLabel = etLabel;
    mSelectedLabel = tvLabel.getText().toString();
    if (clearOtherSelected) {
        clearOtherSelected(false);
    }
}