android.widget.TextView.getText()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(254)

本文整理了Java中android.widget.TextView.getText()方法的一些代码示例,展示了TextView.getText()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.getText()方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:getText

TextView.getText介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
  TextView c = (TextView) v.findViewById(R.id.tvPopUpItem);
  String playerChanged = c.getText().toString();

  Toast.makeText(Settings.this,playerChanged, Toast.LENGTH_SHORT).show();
}

代码示例来源:origin: facebook/stetho

private void doSendMessage() {
 final String message = mConsoleInput.getText().toString();
 mConsoleInput.setText("");
 if (!TextUtils.isEmpty(message)) {
  mConnectionExecutor.execute(new Runnable() {
   @Override
   public void run() {
    mSimpleIRCConnectionManager.send(message);
   }
  });
 }
}

代码示例来源:origin: andkulikov/Transitions-Everywhere

@Override
  public void onAnimationEnd(Animator animation) {
    if (startText.equals(view.getText())) {
      // Only set if it hasn't been changed since anim started
      view.setText(endText);
      if (view instanceof EditText) {
        setSelection(((EditText) view), endSelectionStart,
            endSelectionEnd);
      }
    }
    // restore opaque alpha and correct end color
    view.setTextColor(endColor);
  }
});

代码示例来源:origin: H07000223/FlycoTabLayout

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
      View tabView = mTabsContainer.getChildAt(i);
      tabView.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
      TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
      tv_tab_title.setTextColor(i == mCurrentTab ? mTextSelectColor : mTextUnselectColor);
      tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
//            tv_tab_title.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
      if (mTextAllCaps) {
        tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
      }

      if (mTextBold == TEXT_BOLD_BOTH) {
        tv_tab_title.getPaint().setFakeBoldText(true);
      } else if (mTextBold == TEXT_BOLD_NONE) {
        tv_tab_title.getPaint().setFakeBoldText(false);
      }
    }
  }

代码示例来源:origin: stackoverflow.com

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  View v = inflater.inflate(R.layout.whatever, null);
  vstup = (TextView)v.findViewById(R.id.whatever);
    vstup.setText(savedState.getCharSequence(App.VSTUP));
  state.putCharSequence(App.VSTUP, vstup.getText());
  return state;

代码示例来源:origin: andkulikov/Transitions-Everywhere

@Override
  public void onAnimationEnd(Animator animation) {
    if (startText.equals(view.getText())) {
      // Only set if it hasn't been changed since anim started
      view.setText(endText);
      if (view instanceof EditText) {
        setSelection(((EditText) view), endSelectionStart, endSelectionEnd);
      }
    }
  }
});

代码示例来源:origin: H07000223/FlycoTabLayout

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
      View v = mTabsContainer.getChildAt(i);
//            v.setPadding((int) mTabPadding, v.getPaddingTop(), (int) mTabPadding, v.getPaddingBottom());
      TextView tv_tab_title = (TextView) v.findViewById(R.id.tv_tab_title);
      if (tv_tab_title != null) {
        tv_tab_title.setTextColor(i == mCurrentTab ? mTextSelectColor : mTextUnselectColor);
        tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
        tv_tab_title.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
        if (mTextAllCaps) {
          tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
        }

        if (mTextBold == TEXT_BOLD_BOTH) {
          tv_tab_title.getPaint().setFakeBoldText(true);
        } else if (mTextBold == TEXT_BOLD_NONE) {
          tv_tab_title.getPaint().setFakeBoldText(false);
        }
      }
    }
  }

代码示例来源:origin: stackoverflow.com

listView.setOnItemClickListener(new OnItemClickListener() {
     @Override
     public void onItemClick(AdapterView<?> arg0, View view, int position,long id) {                 
       TextView txtView=(TextView)view.findViewById(R.id.txt_view);
       String fname=txtView.getText().toString().toLowerCase();
               int resID=getResources().getIdentifier(fname, "raw", getPackageName());
              MediaPlayer mediaPlayer=MediaPlayer.create(this,resID);
         mediaPlayer.start();
     }
   });

代码示例来源:origin: ac-pm/Inspeckage

@Override
  public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
    TextView txtPackage = (TextView) v.findViewById(R.id.txtListPkg);
    TextView txtAppName = (TextView) v.findViewById(R.id.txtListItem);
    loadSelectedApp(txtPackage.getText().toString());
    TextView txtAppSelected = (TextView) view.findViewById(R.id.txtAppSelected);
    txtAppSelected.setText(">>> " + txtPackage.getText().toString());
    Toast.makeText(context, "" + txtAppName.getText().toString(), Toast.LENGTH_SHORT).show();
    loadListView(view);
    return true;
  }
});

代码示例来源:origin: andkulikov/Transitions-Everywhere

@Override
  public void onAnimationEnd(Animator animation) {
    if (startText.equals(view.getText())) {
      // Only set if it hasn't been changed since anim started
      view.setText(endText);
      if (view instanceof EditText) {
        setSelection(((EditText) view), endSelectionStart,
            endSelectionEnd);
      }
    }
    // restore opaque alpha and correct end color
    view.setTextColor(endColor);
  }
});

代码示例来源:origin: andkulikov/Transitions-Everywhere

@Override
  public void onAnimationEnd(Animator animation) {
    if (startText.equals(view.getText())) {
      // Only set if it hasn't been changed since anim started
      view.setText(endText);
      if (view instanceof EditText) {
        setSelection(((EditText) view), endSelectionStart, endSelectionEnd);
      }
    }
  }
});

代码示例来源:origin: joyoyao/superCleanMaster

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 (i == selectedPosition) {
        tab.setTextColor(selectedTabTextColor);
      }
    }
  }
}

代码示例来源:origin: stackoverflow.com

LayoutInflater inflater = LayoutInflater.from(YourActivity.this);
final View yourCustomView = inflater.inflate(R.layout.mycustomdialog, null);

final TextView etName = (EditText) yourCustomView.findViewById(R.id.EditZip);
AlertDialog dialog = new AlertDialog.Builder(YourActivity.this)
  .setTitle("Enter the Zip Code")
  .setView(yourCustomView)
  .setPositiveButton("OK", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int whichButton) {
      mSomeVariableYouHaveOnYourActivity = etName.getText().toString();
    }
  })
  .setNegativeButton("Cancel", null).create();
dialog.show();

代码示例来源:origin: wangdan/AisenWeiBo

@Override
  public void onBindViewHolder(ResultViewHolder viewHolder, int position) {
    SearchItem item = mSearchList.get(position);

    int start = 0;
    int end = 0;

    viewHolder.icon_left.setImageResource(item.get_icon());

    if (mTheme == SearchCodes.THEME_LIGHT) {
      viewHolder.icon_left.setColorFilter(ContextCompat.getColor(mContext, com.lapism.searchview.R.color.search_light_icon));
      viewHolder.text.setTextColor(ContextCompat.getColor(mContext, com.lapism.searchview.R.color.search_light_text));

      viewHolder.text.setText(item.get_text(), TextView.BufferType.SPANNABLE);
      Spannable s = (Spannable) viewHolder.text.getText();
//            s.setSpan(new ForegroundColorSpan(ContextCompat.getColor(mContext, com.lapism.searchview.R.color.search_light_text_highlight)), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    if (mTheme == SearchCodes.THEME_DARK) {
      viewHolder.icon_left.setColorFilter(ContextCompat.getColor(mContext, com.lapism.searchview.R.color.search_dark_icon));
      viewHolder.text.setTextColor(ContextCompat.getColor(mContext, com.lapism.searchview.R.color.search_dark_text));

      viewHolder.text.setText(item.get_text(), TextView.BufferType.SPANNABLE);
      Spannable s = (Spannable) viewHolder.text.getText();
      s.setSpan(new ForegroundColorSpan(ContextCompat.getColor(mContext, com.lapism.searchview.R.color.search_dark_text_highlight)), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
  }

代码示例来源:origin: lipangit/JiaoZiVideoPlayer

public void onStateAutoComplete() {
  Log.i(TAG, "onStateAutoComplete " + " [" + this.hashCode() + "] ");
  currentState = CURRENT_STATE_AUTO_COMPLETE;
  cancelProgressTimer();
  progressBar.setProgress(100);
  currentTimeTextView.setText(totalTimeTextView.getText());
}

代码示例来源:origin: H07000223/FlycoTabLayout

View tabView = mTabsContainer.getChildAt(i);
tabView.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
tv_tab_title.setTextColor(i == mCurrentTab ? mTextSelectColor : mTextUnselectColor);
tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
  tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
if (mIconVisible) {
  iv_tab_icon.setVisibility(View.VISIBLE);

代码示例来源:origin: smuyyh/BookReader

@Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    mListPopupWindow.dismiss();
    TextView tv = (TextView) view.findViewById(R.id.tvAutoCompleteItem);
    String str = tv.getText().toString();
    search(str);
  }
});

代码示例来源:origin: fython/MaterialStepperView

/**
 * Update summary view
 */
private void updateSummaryView() {
  mSummaryText.setText(
      mErrorText != null ? mErrorText
          : (mSummaryFinished != null && mState == STATE_DONE) ? mSummaryFinished : mSummary
  );
  mSummaryText.setVisibility(
      (mState != STATE_SELECTED || mAlwaysShowSummary) && !TextUtils.isEmpty(mSummaryText.getText()) ?
          View.VISIBLE : View.GONE
  );
}

代码示例来源:origin: aurelhubert/ahbottomnavigation

final int currentBackgroundColor = AHNotificationHelper.getBackgroundColor(notificationItem, notificationBackgroundColor);
final TextView notification = (TextView) views.get(i).findViewById(R.id.bottom_navigation_notification);
String currentValue = notification.getText().toString();
boolean animate = !currentValue.equals(String.valueOf(notificationItem.getText()));
if (notificationItem.isEmpty() && notification.getText().length() > 0) {
  notification.setText("");
  if (animate) {
    notification.animate()
  notification.setText(String.valueOf(notificationItem.getText()));
  if (animate) {
    notification.setScaleX(0);

代码示例来源:origin: H07000223/FlycoTabLayout

TextView tab_title = (TextView) currentTabView.findViewById(R.id.tv_tab_title);
mTextPaint.setTextSize(mTextsize);
float textWidth = mTextPaint.measureText(tab_title.getText().toString());
margin = (right - left - textWidth) / 2;
  TextView next_tab_title = (TextView) nextTabView.findViewById(R.id.tv_tab_title);
  mTextPaint.setTextSize(mTextsize);
  float nextTextWidth = mTextPaint.measureText(next_tab_title.getText().toString());
  float nextMargin = (nextTabRight - nextTabLeft - nextTextWidth) / 2;
  margin = margin + mCurrentPositionOffset * (nextMargin - margin);

相关文章

TextView类方法