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.juick.android.MessageMenu.java

public boolean onItemLongClick(final AdapterView parent, View view, final int position, long id) {
    menuActions.clear();/*from ww w  .j  ava2 s  .  c  o  m*/
    listSelectedItem = (JuickMessage) parent.getAdapter().getItem(position);
    JuickMessage secondaryItem = null;
    float x = JuickAdvancedApplication.getLastTouchX();
    float y = JuickAdvancedApplication.getLastTouchY();
    if (listSelectedItem.contextPost != null) {
        secondaryItem = listSelectedItem.contextPost;
    }

    urls = new ArrayList<String>();
    if (listSelectedItem.Photo != null) {
        urls.add(listSelectedItem.Photo);
    }
    if (listSelectedItem.Video != null) {
        urls.add(listSelectedItem.Video);
    }

    collectURLs(listSelectedItem.Text, listSelectedItem.getMID());
    if (secondaryItem != null) {
        collectURLs(secondaryItem.Text, listSelectedItem.getMID());
    }

    if (urls.size() > 0) {
        HashSet<String> added = new HashSet<String>();
        for (final String url : urls) {
            // filter out crap
            if (url.endsWith("hqdefault.jpg") && url.contains("youtube"))
                continue;
            // deduplicate
            if (added.add(url)) {
                menuActions.add(new RunnableItem(url) {
                    @Override
                    public void run() {
                        launchURL(listSelectedItem.getMID(), url);
                    }
                });
            }
        }
    }

    collectMenuActions();

    // Censor - Submit a token for review
    TextView listSelectedTextView = (TextView) view.findViewById(R.id.text);
    int[] loc2 = new int[2];
    listSelectedTextView.getLocationOnScreen(loc2);
    int[] loc1 = new int[2];
    listView.getLocationOnScreen(loc1);
    y -= loc2[1] - loc1[1];
    x -= loc2[0] - loc1[0];
    int offset = getOffsetForPosition(listSelectedTextView, x, y);
    if (offset != -1 && false) {
        final String text = listSelectedTextView.getText().toString();
        final String word = Utils.getWordAtOffset(text, offset);
        if (word != null) {
            menuActions.add(new RunnableItem(
                    activity.getResources().getString(R.string.CensorSubmitTokenForReview1) + " \"" + word
                            + "\" " + activity.getResources().getString(R.string.CensorSubmitTokenForReview2)) {
                @Override
                public void run() {
                    actionSubmitTokenForReview(word);
                }
            });
        } else {
            Toast.makeText(activity, activity.getResources().getString(R.string.CensorSubmitWordSelectionError),
                    Toast.LENGTH_LONG).show();
        }
    }
    runActions();
    return true;
}

From source file:com.astuetz.PagerSlidingTrilateralStrip.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);
            //?item,,??
            /*add by HJ begin ??*/
            if (pager.getCurrentItem() == i) {
                //
                tab.setTextColor(tabSelectedTextColor);
            } else {
                //?
                tab.setTextColor(tabNormalTextColor);
            }//from  w  w w .  j  a v a  2  s. c o m
            /*add by HJ end ??*/
            // 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:net.idlesoft.android.apps.github.activities.Repository.java

public void loadRepoInfo() {
    try {//w  w w.j a va  2 s .  c om
        // TextView title =
        // (TextView)findViewById(R.id.tv_top_bar_title);
        // title.setText(m_jsonData.getString("name"));
        final TextView repo_name = (TextView) findViewById(R.id.tv_repository_info_name);
        repo_name.setText(mJson.getString("name"));
        repo_name.requestFocus();
        final TextView repo_desc = (TextView) findViewById(R.id.tv_repository_info_description);
        repo_desc.setText(mJson.getString("description"));
        final TextView repo_owner = (TextView) findViewById(R.id.tv_repository_info_owner);
        repo_owner.setText(mJson.getString("owner"));
        final TextView repo_watcher_count = (TextView) findViewById(R.id.tv_repository_info_watchers);
        if (mJson.getInt("watchers") == 1) {
            repo_watcher_count.setText(mJson.getInt("watchers") + " watcher");
        } else {
            repo_watcher_count.setText(mJson.getInt("watchers") + " watchers");
        }
        final TextView repo_fork_count = (TextView) findViewById(R.id.tv_repository_info_forks);
        if (mJson.getInt("forks") == 1) {
            repo_fork_count.setText(mJson.getInt("forks") + " fork");
        } else {
            repo_fork_count.setText(mJson.getInt("forks") + " forks");
        }
        final TextView repo_website = (TextView) findViewById(R.id.tv_repository_info_website);
        if (mJson.getString("homepage") != "") {
            repo_website.setText(mJson.getString("homepage"));
        } else {
            repo_website.setText("N/A");
        }

        /* Make the repository owner text link to his/her profile */
        repo_owner.setMovementMethod(LinkMovementMethod.getInstance());
        final Spannable spans = (Spannable) repo_owner.getText();
        final ClickableSpan clickSpan = new ClickableSpan() {
            @Override
            public void onClick(final View widget) {
                final Intent i = new Intent(Repository.this, Profile.class);
                try {
                    i.putExtra("username", mJson.getString("owner"));
                } catch (final JSONException e) {
                    e.printStackTrace();
                }
                startActivity(i);
            }
        };
        spans.setSpan(clickSpan, 0, spans.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } catch (final JSONException e) {
        e.printStackTrace();
    }

    ((Button) findViewById(R.id.btn_repository_info_branches)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            final Intent intent = new Intent(Repository.this, BranchesList.class);
            intent.putExtra("repo_name", mRepositoryName);
            intent.putExtra("repo_owner", mRepositoryOwner);
            startActivity(intent);
        }
    });
    ((Button) findViewById(R.id.btn_repository_info_issues)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            final Intent intent = new Intent(Repository.this, Issues.class);
            intent.putExtra("repo_name", mRepositoryName);
            intent.putExtra("repo_owner", mRepositoryOwner);
            startActivity(intent);
        }
    });
    ((Button) findViewById(R.id.btn_repository_info_network)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            final Intent intent = new Intent(Repository.this, NetworkList.class);
            intent.putExtra("repo_name", mRepositoryName);
            intent.putExtra("username", mRepositoryOwner);
            startActivity(intent);
        }
    });
}

From source file:org.geometerplus.android.fbreader.network.AuthenticationActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Thread.setDefaultUncaughtExceptionHandler(
            new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));
    setResult(RESULT_CANCELED);/*  w  w w  .j a v a  2  s .co  m*/
    setContentView(R.layout.authentication);

    final Intent intent = getIntent();
    final String host = intent.getStringExtra(HOST_KEY);
    final String area = intent.getStringExtra(AREA_KEY);
    final String username = intent.getStringExtra(USERNAME_KEY);
    final String error = intent.getStringExtra(ERROR_KEY);
    final boolean showSignupLink = intent.getBooleanExtra(SHOW_SIGNUP_LINK_KEY, false);

    myResource = ZLResource.resource("dialog").getResource("AuthenticationDialog");

    setTitle(host != null ? host : myResource.getResource("title").getValue());

    if (area != null && !"".equals(area)) {
        findTextView(R.id.authentication_subtitle).setText(area);
    } else {
        findTextView(R.id.authentication_subtitle).setVisibility(View.GONE);
    }
    final TextView warningView = findTextView(R.id.authentication_unencrypted_warning);
    if ("https".equalsIgnoreCase(intent.getStringExtra(SCHEME_KEY))) {
        warningView.setVisibility(View.GONE);
    } else {
        warningView.setText(myResource.getResource("unencryptedWarning").getValue());
    }
    findTextView(R.id.authentication_username_label).setText(myResource.getResource("login").getValue());
    findTextView(R.id.authentication_password_label).setText(myResource.getResource("password").getValue());

    final TextView usernameView = findTextView(R.id.authentication_username);
    usernameView.setText(username);

    final TextView errorView = findTextView(R.id.authentication_error);
    if (error != null && !"".equals(error)) {
        errorView.setVisibility(View.VISIBLE);
        errorView.setText(error);
    } else {
        errorView.setVisibility(View.GONE);
    }

    if (showSignupLink) {
        findViewById(R.id.authentication_signup_box).setVisibility(View.VISIBLE);
        final TextView signupView = (TextView) findViewById(R.id.authentication_signup);
        signupView.setText(myResource.getResource("register").getValue());
        signupView.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                setResult(RESULT_SIGNUP);
                finish();
            }
        });
    } else {
        findViewById(R.id.authentication_signup_box).setVisibility(View.GONE);
    }

    final ZLResource buttonResource = ZLResource.resource("dialog").getResource("button");

    final Button okButton = findButton(R.id.authentication_ok_button);
    okButton.setText(buttonResource.getResource("ok").getValue());
    okButton.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View v) {
            final Intent data = new Intent();
            data.putExtra(USERNAME_KEY, usernameView.getText().toString());
            data.putExtra(PASSWORD_KEY, findTextView(R.id.authentication_password).getText().toString());
            setResult(RESULT_OK, data);
            finish();
        }
    });

    final Button cancelButton = findButton(R.id.authentication_cancel_button);
    cancelButton.setText(buttonResource.getResource("cancel").getValue());
    cancelButton.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View v) {
            finish();
        }
    });
}

From source file:com.example.testing.myapplication.module.pageSliding.PagerSlidingTabStrip.java

private void addTextTab(final int position, final String title) {
    TextView tab = new TextView(getContext());
    tab.setText(title);// w  w  w .j  a va2 s  .c om
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    tab.setFocusable(true);
    //tab.setOnClickListener(new OnClickListener() {
    //    @Override public void onClick(View v) {
    //        pager.setCurrentItem(position);
    //        v.setSelected(true);
    //    }
    //});

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
            v.setSelected(true);
        }
    });

    tab.setPadding(tabPadding, 0, tabPadding, 0);
    tab.setBackgroundResource(tabBackgroundResId);
    tab.setTextColor(mTabTextColor);
    tab.setTextSize(tabTextSize);
    //tab.setTypeface(tabTypeface, tabTypefaceStyle);

    tab.setSelected(position == 0);

    // 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));
        }
    }

    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.bob.googleplay.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;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // ################??###################
            // ?item,??
            if (pager.getCurrentItem() == i) {
                // 
                tab.setTextColor(tabSelectedTextColor);
            } else {
                // 
                tab.setTextColor(tabNormalTextColor);
            }// ww  w.j  a v  a  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.amrutpatil.makeanote.NotesActivity.java

private void moveToArchive(View view, int position) {
    ContentValues contentValues = new ContentValues();
    TextView title = (TextView) findViewById(R.id.title_note_custom_home);
    TextView description = (TextView) findViewById(R.id.description_note_custom_home);
    TextView dateTime = (TextView) findViewById(R.id.date_time_note_custom_home);

    LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.home_list);
    int isList = linearLayout.getVisibility();
    String listDescription = "";
    if (isList == View.VISIBLE) {
        //If a note contains list of items
        NoteCustomList noteCustomList = (NoteCustomList) linearLayout.getChildAt(0);
        listDescription = noteCustomList.getLists();
        //            for(int i = 0 ; i < noteCustomList.getChildCount(); i++){
        //                LinearLayout first = (LinearLayout) linearLayout.getChildAt(i);
        //                CheckBox checkBox = (CheckBox) first.getChildAt(0);
        //                TextView textView = (TextView) first.getChildAt(1);
        //                listDescription = description + textView.toString() + checkBox.isChecked() + "%";
        //            }
        contentValues.put(ArchivesContract.ArchivesColumns.ARCHIVES_TYPE, AppConstant.LIST);
    } else {/*from   w  ww  .  jav a 2  s  .com*/
        listDescription = description.getText().toString();
        contentValues.put(ArchivesContract.ArchivesColumns.ARCHIVES_TYPE, AppConstant.NORMAL);
    }

    contentValues.put(ArchivesContract.ArchivesColumns.ARCHIVES_DESCRIPTION, listDescription);
    contentValues.put(ArchivesContract.ArchivesColumns.ARCHIVES_TITLE, title.getText().toString());
    contentValues.put(ArchivesContract.ArchivesColumns.ARCHIVES_DATE_TIME, dateTime.getText().toString());
    contentValues.put(ArchivesContract.ArchivesColumns.ARCHIVES_CATEGORY, mTitle);

    ContentResolver cr = this.getContentResolver();
    Uri uri = ArchivesContract.URI_TABLE;
    cr.insert(uri, contentValues);
    delete(view, position);
}

From source file:com.bowen.hannengclub.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;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);// ?

            // ############ ?? ##############
            // ######  ############
            if (i == pager.getCurrentItem()) {
                // 
                tab.setTextColor(tabTextSelectedColor);
            } else {
                // 
                tab.setTextColor(tabTextNormalColor);
            }/*from   w w  w. j a  v  a 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.zertinteractive.wallpaper.MainActivity.java

@Override
public void onItemTextClick(View view, ViewTextModel mViewTextModel) {
    if (!isSearchingRunning) {
        TextView textView = (TextView) view.findViewById(R.id.grid_item_label);
        searchKey.setText(textView.getText().toString());
        searchActionMethod();// w w w .ja  v  a  2 s.com
    }
}

From source file:com.gelakinetic.mtgfam.fragments.CardViewFragment.java

/**
 * Called when a registered view is long-pressed. The menu inflated will give different options based on the view class
 *
 * @param menu     The context menu that is being built
 * @param v        The view for which the context menu is being built
 * @param menuInfo Extra information about the item for which the context menu should be shown. This information
 *                 will vary depending on the class of v.
 *//*w ww.j  a  v  a  2 s .  c  o  m*/
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {

    super.onCreateContextMenu(menu, v, menuInfo);

    TextView tv = (TextView) v;

    assert tv.getText() != null;
    mCopyString = tv.getText().toString();

    android.view.MenuInflater inflater = this.mActivity.getMenuInflater();
    inflater.inflate(R.menu.copy_menu, menu);
}