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.example.android.wearable.quiz.MainActivity.java

/**
 * Marks a question as "left blank" when its corresponding question notification is deleted.
 *//*w ww. j ava2  s  .  c  o  m*/
private void markQuestionLeftBlank(int index) {
    LinearLayout questionStatusElement = (LinearLayout) questionsContainer.getChildAt(index);
    if (questionStatusElement != null) {
        TextView questionText = (TextView) questionStatusElement.findViewById(R.id.question);
        TextView questionStatus = (TextView) questionStatusElement.findViewById(R.id.status);
        if (questionStatus.getText().equals(getString(R.string.question_unanswered))) {
            questionText.setTextColor(Color.YELLOW);
            questionStatus.setText(R.string.question_left_blank);
            mNumSkipped++;
        }
    }
}

From source file:com.door43.translationstudio.RobotiumTests.java

public void test06TestFrameSwipeNavigation() {
    act.waitForLoad();/*from w ww . j  av a 2 s .c o m*/
    int title = R.id.translationNoteReferenceEditText;
    ArrayList<View> cvs;
    //ArrayList<EditText> etViews = solo.getCurrentViews(EditText.class);
    boolean isChapter = solo.waitForText("Chapter", 1, 30000);
    boolean isFrame = solo.waitForText("Frame", 1, 30000);
    boolean isTranslation = solo.waitForText("Afaraf: [Chapter 1]", 1, 30000);
    EditText et = (EditText) solo.getView(R.id.inputText);

    TextView tTitle = (TextView) solo.getView(R.id.translationTitleText);
    isTranslation = tTitle.getText().toString().endsWith("[Chapter 1]");
    assertTrue("Failed to find translation view.", isTranslation);
    assertNotNull("Could not find id.inputText", et);
    ArrayList<TextView> tvs = solo.getCurrentViews(TextView.class);
    View pView = solo.getView(R.id.readSourceTranslation);
    act.nextFrame();
    solo.sleep(9000);//TODO: need to figure out how to waIT FOR SPINNER STOP
    act.prevFrame();
    assertTrue(true);
    //TODO: navigate to last frame then back
}

From source file:com.example.hudpassthrough.BluetoothChat.java

private void setupChat() {
    // Initialize the array adapter for the conversation thread
    mConversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message);
    mConversationView = (ListView) findViewById(R.id.in);
    mConversationView.setAdapter(mConversationArrayAdapter);

    // Initialize the compose field with a listener for the return key
    mOutEditText = (EditText) findViewById(R.id.edit_text_out);
    mOutEditText.setOnEditorActionListener(mWriteListener);

    // Initialize the send button with a listener that for click events
    mSendButton = (Button) findViewById(R.id.button_send);
    mSendButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            // Send a message using content of the edit text widget
            TextView view = (TextView) findViewById(R.id.edit_text_out);
            String message = view.getText().toString();
            sendMessage(message);/*  w w w .j a  v  a  2  s  .c o m*/
        }
    });

    // Initialize the BluetoothChatService to perform bluetooth connections
    mChatService = new BluetoothChatService(this, mHandler);

    // Initialize the buffer for outgoing messages
    mOutStringBuffer = new StringBuffer("");
}

From source file:com.feathercoin.wallet.feathercoin.ui.EditAddressBookEntryFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final String address = args.getString(KEY_ADDRESS);
    final String suggestedAddressLabel = args.getString(KEY_SUGGESTED_ADDRESS_LABEL);

    final LayoutInflater inflater = LayoutInflater.from(activity);

    final Uri uri = AddressBookProvider.contentUri(activity.getPackageName()).buildUpon().appendPath(address)
            .build();/*from w w w .j a  va 2s .  c om*/

    final String label = AddressBookProvider.resolveLabel(activity, address);

    final boolean isAdd = label == null;

    final AlertDialog.Builder dialog = new AlertDialog.Builder(activity);
    dialog.setInverseBackgroundForced(true);
    dialog.setTitle(isAdd ? R.string.edit_address_book_entry_dialog_title_add
            : R.string.edit_address_book_entry_dialog_title_edit);

    final View view = inflater.inflate(R.layout.edit_address_book_entry_dialog, null);

    final TextView viewAddress = (TextView) view.findViewById(R.id.edit_address_book_entry_address);
    viewAddress.setText(WalletUtils.formatHash(address, Constants.ADDRESS_FORMAT_GROUP_SIZE,
            Constants.ADDRESS_FORMAT_LINE_SIZE));

    final TextView viewLabel = (TextView) view.findViewById(R.id.edit_address_book_entry_label);
    viewLabel.setText(label != null ? label : suggestedAddressLabel);

    dialog.setView(view);

    final DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
        public void onClick(final DialogInterface dialog, final int which) {
            if (which == DialogInterface.BUTTON_POSITIVE) {
                final String newLabel = viewLabel.getText().toString().trim();

                if (newLabel.length() > 0) {
                    final ContentValues values = new ContentValues();
                    values.put(AddressBookProvider.KEY_LABEL, newLabel);

                    if (isAdd)
                        contentResolver.insert(uri, values);
                    else
                        contentResolver.update(uri, values, null, null);
                } else if (!isAdd) {
                    contentResolver.delete(uri, null, null);
                }
            } else if (which == DialogInterface.BUTTON_NEUTRAL) {
                contentResolver.delete(uri, null, null);
            }

            dismiss();
        }
    };

    dialog.setPositiveButton(isAdd ? R.string.button_add : R.string.edit_address_book_entry_dialog_button_edit,
            onClickListener);
    if (!isAdd)
        dialog.setNeutralButton(R.string.button_delete, onClickListener);
    dialog.setNegativeButton(R.string.button_cancel, onClickListener);

    return dialog.create();
}

From source file:com.door43.translationstudio.RobotiumTests.java

public void test09ReadChapter() {
    act.waitForLoad();//  ww  w. j a  va2s .  c  o m
    int title = R.id.translationNoteReferenceEditText;
    ArrayList<View> cvs;
    //ArrayList<EditText> etViews = solo.getCurrentViews(EditText.class);
    boolean isChapter = solo.waitForText("Chapter", 1, 30000);
    boolean isFrame = solo.waitForText("Frame", 1, 30000);
    boolean isTranslation = solo.waitForText("Afaraf: [Chapter 1]", 1, 30000);
    EditText et = (EditText) solo.getView(R.id.inputText);

    TextView tTitle = (TextView) solo.getView(R.id.translationTitleText);
    isTranslation = tTitle.getText().toString().endsWith("[Chapter 1]");

    assertTrue("Failed to find translation view.", isTranslation);
    assertNotNull("Could not find id.inputText", et);
    View pView = solo.getView(R.id.sourceTitleText);
    ArrayList<Button> btns = solo.getCurrentViews(Button.class);
    View cButton = solo.getView(R.id.contextual_menu_btn);
    assertTrue("Failed to find contextual menu button.", cButton.getVisibility() == View.VISIBLE);
    solo.clickOnView(cButton);
    solo.sleep(1000);
    solo.clickOnMenuItem("Read chapter");
    solo.sleep(1000);
    ArrayList<ListView> lvs = solo.getCurrentViews(ListView.class);
    TextView tv = solo.getText("Solomon was the father", true);
    assertNotNull("Unexpectedly found chapter", tv);
}

From source file:com.heath_bar.tvdb.EpisodeDetails.java

@Override
public void onDialogPositiveClick(DialogFragment dialog) {
    TextView valueText = (TextView) dialog.getDialog().findViewById(R.id.value);
    new UpdateRatingTask().execute(userAccountId, String.valueOf(seriesId), String.valueOf(episodeId),
            valueText.getText().toString());
}

From source file:it.scoppelletti.mobilepower.app.MarketTagHandler.java

/**
 * Attiva la rilevazione dei collegamenti.
 * /*from w ww. java  2s.c  o m*/
 * @param view    Controllo.
 * @param pkgName Nome del pacchetto.
 */
public void addLinks(TextView view, String pkgName) {
    String text;

    if (myEndPos <= myStartPos || StringUtils.isBlank(pkgName)) {
        return;
    }

    myPkgName = pkgName;

    // http://www.indelible.org/ink/android-linkify, 09/04/2010
    // La rilevazione dei collegamenti personalizzati e' attiva solo
    // disabilitando la rilevazione dei collegamenti di default e 
    // riabilitandola attraverso la classe Linkify.
    view.setAutoLinkMask(0);

    Linkify.addLinks(view, Linkify.ALL);
    text = String.valueOf(view.getText().subSequence(myStartPos, myEndPos));
    Linkify.addLinks(view, Pattern.compile(text), MarketTagHandler.SCHEME, this, this);
}

From source file:com.door43.translationstudio.RobotiumTests.java

public void test05EnableDisableBlindDraftMode() {
    act.waitForLoad();//from  www.ja v a2s . co  m
    int title = R.id.translationNoteReferenceEditText;
    ArrayList<View> cvs;
    //ArrayList<EditText> etViews = solo.getCurrentViews(EditText.class);
    boolean isChapter = solo.waitForText("Chapter", 1, 30000);
    boolean isFrame = solo.waitForText("Frame", 1, 30000);
    boolean isTranslation = solo.waitForText("Afaraf: [Chapter 1]", 1, 30000);
    EditText et = (EditText) solo.getView(R.id.inputText);

    TextView tTitle = (TextView) solo.getView(R.id.translationTitleText);
    isTranslation = tTitle.getText().toString().endsWith("[Chapter 1]");
    assertTrue("Failed to find translation view.", isTranslation);
    assertNotNull("Could not find id.inputText", et);
    View pView = solo.getView(R.id.sourceTitleText);
    ArrayList<Button> btns = solo.getCurrentViews(Button.class);
    View cButton = solo.getView(R.id.contextual_menu_btn);
    assertTrue("Failed to find contextual menu button.", cButton.getVisibility() == View.VISIBLE);
    solo.clickOnView(cButton);
    solo.sleep(1000);
    solo.clickOnMenuItem("Toggle blind draft");
    solo.sleep(1000);
    ArrayList<TextView> textViews = solo.getCurrentViews(TextView.class);
    assertFalse("Unexpectedly found source view", textViews.contains(pView));
    solo.clickOnView(cButton);
    solo.sleep(1000);
    solo.clickOnMenuItem("Toggle blind draft");
    solo.sleep(1000);
    pView = solo.getView(R.id.sourceTitleText);
    boolean isSourceView = solo.waitForView(R.id.sourceTitleText, 1, 5000);
    assertTrue(isSourceView);
}

From source file:com.he5ed.lib.cloudprovider.picker.CloudPickerActivity.java

/**
 * @hide//  w  w  w .j  a  va  2 s  . c  om
 */
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    // save empty view state skip if not visible
    LinearLayout emptyView = (LinearLayout) findViewById(R.id.error_view);
    outState.putInt("empty_view_visibility", emptyView.getVisibility());
    if (emptyView.getVisibility() != View.VISIBLE)
        return;

    ImageView icon = (ImageView) findViewById(R.id.empty_icon_image_view);
    TextView title = (TextView) findViewById(R.id.empty_title_text_view);
    TextView detail = (TextView) findViewById(R.id.empty_detail_text_view);

    Bitmap bitmap = ((BitmapDrawable) icon.getDrawable()).getBitmap();
    outState.putParcelable("icon_drawable", bitmap);
    outState.putCharSequence("title_text", title.getText());
    outState.putCharSequence("detail_text", detail.getText());
}

From source file:com.chatwing.whitelabel.adapters.ConversationsAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    Conversation conversation = ConversationTable.getConversation(cursor);

    TextView aliasTv = (TextView) view.findViewById(android.R.id.text1);
    aliasTv.setText(conversation.getConversationAlias(mCurrentUser.getId()));

    int countIndexColumn = cursor.getColumnIndex(ConversationTable.UNREAD_COUNT);
    int count = cursor.getInt(countIndexColumn);
    TextView countTv = (TextView) view.findViewById(R.id.unread_count);
    if (count == 0) {
        countTv.setVisibility(View.GONE);
    } else {//from   w  w w.ja  v  a2s .  c o  m
        countTv.setText(String.valueOf(count));
        countTv.setVisibility(View.VISIBLE);
    }

    LogUtils.v("Conversation " + aliasTv.getText() + ":" + conversation.isModerator());
    if (conversation.isModerator()) {
        aliasTv.setTypeface(null, Typeface.ITALIC);
    } else {
        aliasTv.setTypeface(null, Typeface.NORMAL);
    }
}