List of usage examples for android.widget TextView getText
@ViewDebug.CapturedViewProperty
public CharSequence getText()
From source file:com.example.stephenhite.dndnextgen.CharCreateActivity.java
public void HandleCreateCharacter(View view) { TextView nameBox = (TextView) findViewById(R.id.character_name_field); NumberPicker ageBox = (NumberPicker) findViewById(R.id.character_age_field); NumberPicker heightPicker = (NumberPicker) findViewById(R.id.character_height_picker); NumberPicker weightPicker = (NumberPicker) findViewById(R.id.character_weight_picker); Spinner alignmentBox = (Spinner) findViewById(R.id.character_alignment_spinner); creatorCntl.userCharacter.setName(nameBox.getText().toString()); creatorCntl.userCharacter.setAge(ageBox.getValue()); creatorCntl.userCharacter.setHeight(heightPicker.getValue()); creatorCntl.userCharacter.setWeight(weightPicker.getValue()); creatorCntl.userCharacter.setAlignment(alignmentBox.getSelectedItem().toString()); creatorCntl.saveCharacter(this.getBaseContext()); }
From source file:com.microsoft.o365_android_onenote_rest.SnippetDetailFragment.java
@TargetApi(11) private void clipboard11(TextView tv) { android.content.ClipboardManager clipboardManager = (android.content.ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clipData = ClipData.newPlainText("OneNote", tv.getText()); clipboardManager.setPrimaryClip(clipData); }
From source file:com.door43.translationstudio.RobotiumTests.java
public void test00SimpleStartToTranslate() { act.waitForLoad();/*from ww w . j a v a 2 s .c o m*/ boolean isOpen = solo.waitForText("Get more projects", 1, 25000); if (!isOpen) { selectTab(0); isOpen = solo.waitForText("Get more projects", 1, 15000); } if (isOpen) { boolean isNT = act.waitAndClickText("Bible: NT"); boolean isMat = act.waitAndClickText("Matthew", 15000); act.waitAndClickText("English"); solo.waitForText("Loading", 1, 10000); solo.waitForText("Afaraf", 1, 25000); solo.clickInList(0); act.waitAndClickText("Chapter 1"); act.waitAndClickText("1-3"); TextView verseOne2Three = solo.getText("genealogy", true); String expectedString = "The book of the genealogy of Jesus Christ"; String verse = verseOne2Three.getText().toString(); Log.d("TSTEST", verse); boolean expected = verseOne2Three.getText().toString().contains(expectedString); //clickables: Open Bible Stories, bible-ot Bible-NT, Get more projects [CHAPTER & FRAME](are blank) Project returns to main view assertTrue(expected); //TODO: start really testing } else { //cvs = solo.getCurrentViews(); //TODO: query to find the visible view assertEquals(true, false); } }
From source file:com.example.vedantn.algaeestimator.MainActivity.java
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { //Listens to calcMethodSpinner if (parent == (AdapterView) findViewById(R.id.calcMethodSpinner)) { TextView selection = (TextView) view; Toast.makeText(this, selection.getText(), Toast.LENGTH_SHORT).show(); //For making unused components invisible from the main page when calculation mode is selected switch (position) { case 0: { resetView();//from ww w .java 2 s .c o m ((TextView) findViewById(R.id.lblSD)).setVisibility(View.INVISIBLE); ((EditText) findViewById(R.id.tbSD)).setVisibility(View.INVISIBLE); ((Spinner) findViewById(R.id.spinnerSD)).setVisibility(View.INVISIBLE); ((TextView) findViewById(R.id.lblDO)).setVisibility(View.INVISIBLE); ((EditText) findViewById(R.id.tbDO)).setVisibility(View.INVISIBLE); break; } case 1: { resetView(); ((TextView) findViewById(R.id.lblValueOfAlgal)).setVisibility(View.INVISIBLE); ((EditText) findViewById(R.id.tbValueOfAlgal)).setVisibility(View.INVISIBLE); break; } default: { resetView(); } } } //Sets the units for depth (m/f) if (parent == (AdapterView) findViewById(R.id.spinnerDepth)) { if (position == 1) flagDepth = 1; else flagDepth = 0; } //Sets the units for surface temperature (C/F) if (parent == (AdapterView) findViewById(R.id.spinnerStemp)) { if (position == 1) flagStemp = 1; else flagStemp = 0; } //Sets the units for bottom temperature (C/F) if (parent == (AdapterView) findViewById(R.id.spinnerBotTemp)) { if (position == 1) flagBottemp = 1; else flagBottemp = 0; } //Sets the units for Secchi Depth (m/f) if (parent == (AdapterView) findViewById(R.id.spinnerSD)) { if (position == 1) flagSD = 1; else flagSD = 0; } }
From source file:com.tingbacke.wearmaps.MobileActivity.java
private Notification getBasicNotification(String stack) { String title = "Vstra Hamnen"; TextView tv = (TextView) findViewById(R.id.textView3); String text = tv.getText().toString(); // Here I determine the vibration pattern for the notification long[] pattern = { 0, 200, 0 }; /*/*w ww .jav a2 s . c om*/ // This seems only to be for adding longer texts to a notification... NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle(); bigTextStyle.setBigContentTitle(title); */ /* Spannable sb = new SpannableString("Bold this and italic that."); sb.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); sb.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 14, 20, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); */ NotificationCompat.WearableExtender extender = new NotificationCompat.WearableExtender() .setBackground(BitmapFactory.decodeResource(getResources(), R.mipmap.turn)); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); inboxStyle.addLine(Html.fromHtml("<b>Turning Torso</b>")); inboxStyle.addLine(Html.fromHtml("<b>453m away</b>")); return new NotificationCompat.Builder(this).setSmallIcon(R.mipmap.icon_mdpi).setContentTitle(title) .setContentText(text) //.setStyle(bigPic) //.setStyle(inboxStyle) .extend(extender) //.setStyle(bigTextStyle) .setVibrate(pattern).setGroup(stack).build(); }
From source file:com.example.android.MagneticBearingController.BluetoothChatFragment.java
/** * Set up the UI and background operations for chat. *//*from ww w . j ava2 s . c o m*/ private void setupChat() { Log.d(TAG, "setupChat()"); // Initialize the array adapter for the conversation thread mConversationArrayAdapter = new ArrayAdapter<String>(getActivity(), R.layout.message); mConversationView.setAdapter(mConversationArrayAdapter); // Initialize the compose field with a listener for the return key mOutEditText.setOnEditorActionListener(mWriteListener); // Initialize the send button with a listener that for click events mSendButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Send a message using content of the edit text widget View view = getView(); if (null != view) { TextView textView = (TextView) view.findViewById(R.id.edit_text_out); String message = textView.getText().toString(); sendMessage(message); } } }); // Initialize the up button with a listener that for click events mUpButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Send an Up Message String message = getString(R.string.Up_Message); sendMessage(message); if (BearingHeight > 0.1) { BearingHeight = BearingHeight - 0.1; Log.d(TAG, "PrintHeightTrack =" + PrintHeightTrack + "BearingHeight =" + String.format("%.2f", BearingHeight)); if (PrintHeightTrack == 1) { mConversationArrayAdapter.add(mConnectedDeviceName + " Bearing Height: " + String.format("%.2f", BearingHeight) + " mm"); } } } }); // Initialize the Down button with a listener that for click events mDownButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Send an Down Message String message = getString(R.string.Down_Message); sendMessage(message); if (BearingHeight < 1.2) { BearingHeight = BearingHeight + 0.1; if (PrintHeightTrack == 1) { mConversationArrayAdapter.add(mConnectedDeviceName + " Bearing Height: " + String.format("%.2f", BearingHeight) + " mm"); } } } }); // Initialize the Lock/Unlock button with a listener that for click events mLockButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String message; //Get View and Button to change text lock/unlock // View view = getView(); if (null != v) { Button LockButton = (Button) v.findViewById(R.id.LockButton); // Check LockState, Flip it and send Lock/Unlock message if (LockState == 0) { LockState = 1; message = getString(R.string.Lock_Message); LockButton.setText(getString(R.string.Unlock_button)); if (PrintHeightTrack == 1) { mConversationArrayAdapter.add(mConnectedDeviceName + " Bearing Height: " + 0 + " mm"); } } else { LockState = 0; message = getString(R.string.Unlock_Message); LockButton.setText((getString(R.string.Lock_button))); if (PrintHeightTrack == 1) { mConversationArrayAdapter.add(mConnectedDeviceName + " Bearing Height: " + String.format("%.2f", BearingHeight) + " mm"); } } sendMessage(message); } } }); // Initialize the Print Alive Toggle button with a listener that for click events mheightToggleButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // if button is on allow heights to print if (mheightToggleButton.isChecked()) { PrintHeight = 1; } else { PrintHeight = 0; } } }); // Initialize the Print Height Track Toggle button with a listener that for click events mheightTrackToggleButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // if button is on allow heights to print if (mheightTrackToggleButton.isChecked()) { PrintHeightTrack = 1; } else { PrintHeightTrack = 0; } } }); // Initialize the BluetoothChatService to perform bluetooth connections mChatService = new BluetoothChatService(getActivity(), mHandler); // Initialize the buffer for outgoing messages mOutStringBuffer = new StringBuffer(""); }
From source file:com.he5ed.lib.cloudprovider.picker.PickerFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (getView() == null) return;//from www. java2s . c om // save empty view state skip if not visible LinearLayout emptyView = (LinearLayout) getView().findViewById(android.R.id.empty); outState.putInt("empty_view_visibility", emptyView.getVisibility()); if (emptyView.getVisibility() != View.VISIBLE) return; ImageView icon = (ImageView) getView().findViewById(R.id.empty_icon_image_view); TextView title = (TextView) getView().findViewById(R.id.empty_title_text_view); TextView detail = (TextView) getView().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.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java
/** * Format appropriately the suggested word in {@link #mWordViews} specified by * <code>positionInStrip</code>. When the suggested word doesn't exist, the corresponding * {@link TextView} will be disabled and never respond to user interaction. The suggested word * may be shrunk or ellipsized to fit in the specified width. * * The <code>positionInStrip</code> argument is the index in the suggestion strip. The indices * increase towards the right for LTR scripts and the left for RTL scripts, starting with 0. * The position of the most important suggestion is in {@link #mCenterPositionInStrip}. This * usually doesn't match the index in <code>suggedtedWords</code> -- see * {@link #getPositionInSuggestionStrip(int,SuggestedWords)}. * * @param positionInStrip the position in the suggestion strip. * @param width the maximum width for layout in pixels. * @return the {@link TextView} containing the suggested word appropriately formatted. */// w ww . j a v a 2 s . c o m private TextView layoutWord(final int positionInStrip, final int width) { final TextView wordView = mWordViews.get(positionInStrip); final CharSequence word = wordView.getText(); if (positionInStrip == mCenterPositionInStrip && mMoreSuggestionsAvailable) { // TODO: This "more suggestions hint" should have a nicely designed icon. wordView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, mMoreSuggestionsHint); // HACK: Align with other TextViews that have no compound drawables. wordView.setCompoundDrawablePadding(-mMoreSuggestionsHint.getIntrinsicHeight()); } else { wordView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); } // {@link StyleSpan} in a content description may cause an issue of TTS/TalkBack. // Use a simple {@link String} to avoid the issue. wordView.setContentDescription(TextUtils.isEmpty(word) ? null : word.toString()); final CharSequence text = getEllipsizedText(word, width, wordView.getPaint()); final float scaleX = getTextScaleX(word, width, wordView.getPaint()); wordView.setText(text); // TextView.setText() resets text scale x to 1.0. wordView.setTextScaleX(Math.max(scaleX, MIN_TEXT_XSCALE)); // A <code>wordView</code> should be disabled when <code>word</code> is empty in order to // make it unclickable. // With accessibility touch exploration on, <code>wordView</code> should be enabled even // when it is empty to avoid announcing as "disabled". wordView.setEnabled( !TextUtils.isEmpty(word) || AccessibilityUtils.getInstance().isTouchExplorationEnabled()); return wordView; }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java
private void layoutDebugInfo(final int positionInStrip, final ViewGroup placerView, final int x) { final TextView debugInfoView = mDebugInfoViews.get(positionInStrip); final CharSequence debugInfo = debugInfoView.getText(); if (debugInfo == null) { return;/* w w w . j a v a2 s. c om*/ } placerView.addView(debugInfoView); debugInfoView.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); final int infoWidth = debugInfoView.getMeasuredWidth(); final int y = debugInfoView.getMeasuredHeight(); ViewLayoutUtils.placeViewAt(debugInfoView, x - infoWidth, y, infoWidth, debugInfoView.getMeasuredHeight()); }
From source file:com.example.android.bluetoothchat.BluetoothChatFragment2.java
/** * Set up the UI and background operations for chat. *//* ww w . ja v a2s . c om*/ private void setupChat() { Log.d(TAG, "setupChat()"); // Initialize the array adapter for the conversation thread mConversationArrayAdapter = new ArrayAdapter<String>(getActivity(), R.layout.message); mConversationView.setAdapter(mConversationArrayAdapter); // Initialize the compose field with a listener for the return key mOutEditText.setOnEditorActionListener(mWriteListener); // Initialize the send button with a listener that for click events mSendButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Send a message using content of the edit text widget View view = getView(); if (null != view) { TextView textView = (TextView) view.findViewById(R.id.edit_text_out); String message = textView.getText().toString(); sendMessage(message); } } }); // Initialize the buffer for outgoing messages mOutStringBuffer = new StringBuffer(""); }