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

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

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

TextView.setHint介绍

暂无

代码示例

代码示例来源:origin: JessYanCoding/MVPArms

/**
 * 设置hint大小
 *
 * @param size
 * @param v
 * @param res
 */
public static void setViewHintSize(Context context, int size, TextView v, int res) {
  SpannableString ss = new SpannableString(getResources(context).getString(
      res));
  // 新建一个属性对象,设置文字的大小
  AbsoluteSizeSpan ass = new AbsoluteSizeSpan(size, true);
  // 附加属性到文本  
  ss.setSpan(ass, 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  // 设置hint  
  v.setHint(new SpannedString(ss)); // 一定要进行转换,否则属性会消失
}

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

// Setting up the TextView of searchView suggestions drop down list
for (TextView textView : findChildrenByClass(mSearchView, TextView.class)) {
   textView.setHint("Type a word");
   textView.setTextColor(Color.rgb(255, 255, 255));
   textView.setHintTextColor(Color.argb(128, 255, 255, 255));
}

代码示例来源:origin: willowtreeapps/Hyperion-Android

@Override
  protected void mutate(CharSequence value) {
    view.setHint(value);
  }
});

代码示例来源:origin: sendtion/XRichText

/**
 * 生成文本输入框
 */
public TextView createTextView(String hint, int paddingTop) {
  TextView textView = (TextView) inflater.inflate(R.layout.rich_textview, null);
  textView.setTag(viewTagIndex++);
  textView.setPadding(editNormalPadding, paddingTop, editNormalPadding, paddingTop);
  textView.setHint(hint);
  //textView.setTextSize(getResources().getDimensionPixelSize(R.dimen.text_size_16));
  textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, rtTextSize);
  textView.setLineSpacing(rtTextLineSpace, 1.0f);
  textView.setTextColor(rtTextColor);
  return textView;
}

代码示例来源:origin: xiepeijie/SwipeCardView

holder.cityView.setHint(no);
holder.cityView.setText(talent.cityName);
holder.cityView.setCompoundDrawablesWithIntrinsicBounds(0,R.drawable.home01_icon_location,0,0);
holder.eduView.setHint(no);
holder.eduView.setText(talent.educationName);
holder.eduView.setCompoundDrawablesWithIntrinsicBounds(0,R.drawable.home01_icon_edu,0,0);
holder.workView.setHint(no);
holder.workView.setText(talent.workYearName);
holder.workView.setCompoundDrawablesWithIntrinsicBounds(0,R.drawable.home01_icon_work_year,0,0);

代码示例来源:origin: mohak1712/UberUX

@Override
public void onTransitionStart(Transition transition) {
  InputMethodManager imm = (InputMethodManager) getSystemService(
      Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(etPhoneNo.getWindowToken(), 0);
  tvMoving.setText(null);
  tvMoving.setHint(getString(R.string.enter_no));
  ivFlag.setImageAlpha(0);
  tvCode.setAlpha(0);
  etPhoneNo.setVisibility(View.GONE);
  etPhoneNo.setCursorVisible(false);
  etPhoneNo.setBackground(null);
  Animation animation = AnimationUtils.loadAnimation(LoginWithPhone.this, R.anim.slide_left);
  ivBack.startAnimation(animation);
}

代码示例来源:origin: flipkart-incubator/proteus

@Override
 public void setString(T view, String value) {
  view.setHint(value);
 }
});

代码示例来源:origin: LightSun/data-mediator

@Override
  protected void apply(Property prop, View view, Object newValue) {
    ((TextView)view).setHint((CharSequence) newValue);
  }
}

代码示例来源:origin: LightSun/data-mediator

@Override
  protected void apply(Property prop, View view, Object newValue) {
    ((TextView)view).setHint((Integer) newValue);
  }
}

代码示例来源:origin: hamidness/restring

private void setHintForView(View view, String text) {
    ((TextView) view).setHint(text);
  }
}

代码示例来源:origin: dongorigin/AndroidDemo

@Override
  public void afterTextChanged(Editable s) {
    int inputCount = s.toString().length();
    mContentHint.setHint("当前字数: " + inputCount);
    updateContentSize();
  }
});

代码示例来源:origin: CB-ysx/CBRatingBar

@Override
  public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
    cbRatingBar.setCanTouch(b);
    if (b) {
      showTouch.setHint("可点击");
    } else {
      showTouch.setHint("不能点击");
    }
    if (!b) {
      showTouch.setText("");
    }
  }
});

代码示例来源:origin: Tencent/RapidView

public void run(RapidParserObject object, Object view, Var value) {
    ((TextView)view).setHint(value.getString());
  }
}

代码示例来源:origin: nurkiewicz/rxjava-book-examples

@Override public void call(CharSequence hint) {
  view.setHint(hint);
 }
};

代码示例来源:origin: nurkiewicz/rxjava-book-examples

@Override public void call(Integer hintRes) {
  view.setHint(hintRes);
 }
};

代码示例来源:origin: JustinRoom/JSCKit

public void init(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
  setOrientation(HORIZONTAL);
  labelTextView = new TextView(context);
  addView(labelTextView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  valueTextView = new TextView(context);
  valueTextView.setGravity(Gravity.END);
  addView(valueTextView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
  labelTextView.setHint("label");
  valueTextView.setHint("value");
  setTextSize(14, 14);
  setTextColor(0xFF666666, 0xFF333333);
}

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

public static void setSearchViewEditTextHint(Context context, SearchView searchView, int stringId){
  int searchMagIconId = context.getResources().getIdentifier("android:id/search_src_text", null, null);
  TextView textView = (TextView) searchView.findViewById(searchMagIconId);
  if (null != textView) {
    textView.setHint(stringId);
  }
}

代码示例来源:origin: dkharrat/NexusDialog

@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
  View view = super.getView(position, convertView, parent);
  if (position == getCount()) {
    TextView itemView = ((TextView)view.findViewById(android.R.id.text1));
    itemView.setText("");
    itemView.setHint(getItem(getCount()));
  }
  return view;
}

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

TextView text = (TextView)findViewById(R.id.text);

String simple = "First Name ";
String colored = "*";
SpannableStringBuilder builder = new SpannableStringBuilder();

builder.append(simple);
int start = builder.length();
builder.append(colored);
int end = builder.length();

builder.setSpan(new ForegroundColorSpan(Color.RED), start, end, 
        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

text.setHint(builder);

代码示例来源:origin: geniusgithub/AndroidDialer

/**
 * Sets the hint text for the contacts search box
 */
private void setSearchBoxHint() {
  SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) getSupportActionBar()
      .getCustomView().findViewById(R.id.search_view_container);
  ((TextView) searchEditTextLayout.findViewById(R.id.search_box_start_search))
      .setHint(getSearchBoxHint());
}

相关文章

TextView类方法