本文整理匯總了Java中android.widget.TextView.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java TextView.setText方法的具體用法?Java TextView.setText怎麽用?Java TextView.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.TextView
的用法示例。
在下文中一共展示了TextView.setText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: AmountPicker
import android.widget.TextView; //導入方法依賴的package包/類
public AmountPicker(Context context, int decimals) {
super(context);
integers = new NumberPicker[Math.max(0, 5-decimals)];
fractions = new NumberPicker[decimals];
int totalWidth = 6*getResources().getDimensionPixelSize(R.dimen.amount_picker_width);
int total = integers.length + fractions.length;
int pickerWidth = totalWidth/total;
setOrientation(HORIZONTAL);
LinearLayout.LayoutParams lpFixedWrap = new LinearLayout.LayoutParams(pickerWidth, LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams lpWrapFill = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
addPickers(context, lpFixedWrap, integers);
if (decimals > 0) {
TextView dotText = new TextView(context);
dotText.setText(".");
dotText.setGravity(Gravity.BOTTOM);
dotText.setTextSize(pickerWidth/2);
addView(dotText, lpWrapFill);
addPickers(context, lpFixedWrap, fractions);
}
}
示例2: onTouch
import android.widget.TextView; //導入方法依賴的package包/類
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN && !stackedLayout.empty()) {
LetterTile tile = (LetterTile) stackedLayout.peek();
tile.moveToViewGroup((ViewGroup) v);
if (stackedLayout.empty()) {
TextView messageBox = (TextView) findViewById(R.id.message_box);
messageBox.setText(word1 + " " + word2);
}
/**
**
** YOUR CODE GOES HERE
**
**/
return true;
}
return false;
}
示例3: updateTextAndColor
import android.widget.TextView; //導入方法依賴的package包/類
private void updateTextAndColor(TextView categoryView, int count, TextView countView, int[] colors) {
categoryView.setBackgroundColor(colors[2]);
categoryView.setTextColor(colors[3]);
GradientDrawable countD = new GradientDrawable();
countD.setColor(colors[0]);
countD.setCornerRadius(countView.getHeight() / 2);
countView.setBackground(countD);
countView.setTextColor(colors[1]);
int c = count;
if (countView == mCountRecent) {
int recent = activity.getResources().getInteger(R.integer.sheet_recent_count);
c = count > recent ? recent : c;
}
countView.setText(String.valueOf(c));
}
示例4: onCreateView
import android.widget.TextView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
log.i("onCreateView");
View rootView = inflater.inflate(R.layout.fragment_billing, container, false);
txt_content = (TextView) rootView.findViewById(R.id.txt_content);
txt_content.setText(this.getClass().getSimpleName());
bill_type = (Spinner) rootView.findViewById(R.id.bill_type);
bill_sku = (Spinner) rootView.findViewById(R.id.bill_sku);
String[] testSkus = getResources().getStringArray(R.array.bill_skus);
for (String sku : testSkus) {
mSkuList.add(sku);
}
mSkuAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, mSkuList);
mSkuAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
bill_sku.setAdapter(mSkuAdapter);
return rootView;
}
示例5: onActivityResult
import android.widget.TextView; //導入方法依賴的package包/類
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case 0:
TextView localFolder = (TextView) findViewById(R.id.localFolder);
if (data==null || data.getExtras()==null) return;
String choosedFolder = data.getExtras().getString(EDFileChooserActivity.PARAM_KEY_PATH);
EncdroidFileProvider originProvider = (EncdroidFileProvider)data.getSerializableExtra(EDFileChooserActivity.PARAM_KEY_PROVIDER);
String importPath = new File( originProvider.getAbsolutePath(choosedFolder)).getAbsolutePath();
localFolder.setText(importPath);
}
}
示例6: getView
import android.widget.TextView; //導入方法依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TGBrowserSettingsFolderAdapterItem item = this.items.get(position);
View view = (convertView != null ? convertView : getLayoutInflater().inflate(R.layout.view_browser_element, parent, false));
view.setTag(item);
TextView textView = (TextView) view.findViewById(R.id.tg_browser_element_name);
textView.setText(item.getLabel());
Drawable styledIcon = this.findStyledFolderIcon();
if( styledIcon != null ) {
ImageView imageView = (ImageView) view.findViewById(R.id.tg_browser_element_icon);
imageView.setImageDrawable(styledIcon);
}
view.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
updatePath(((TGBrowserSettingsFolderAdapterItem) v.getTag()).getFile());
}
});
return view;
}
示例7: newView
import android.widget.TextView; //導入方法依賴的package包/類
@Override
public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
View view=layoutInflater.inflate(R.layout.item_view,null);
TextView item=(TextView)view;
item.setText(cursor.getString(cursor.getColumnIndex("_id")));
TextView textView= view.findViewById(R.id.point_item_tv);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG, "onClick: select lineId is "+textView.getText());
realTimeBusQueryActivity.lineNumber_actv.setText(textView.getText());
realTimeBusQueryActivity.showFromAndToStation((String) textView.getText());
}
});
return view;
}
示例8: onCreate
import android.widget.TextView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mMainText = (TextView) findViewById(R.id.main_text);
// If you plan to run this application on different devices (not on YotaPhone only), you
// may want to check if this device is YotaPhone before starting Epd activity. You could
// use Build.DEVICE for this.
if (!Build.DEVICE.contains(YOTAPHONE)) {
// This device is not a YotaPhone, say "Hello! This is not a YotaPhone!"
mMainText.setText(getString(R.string.hello_strange_phone));
} else {
// This device is a YotaPhone, say "Hello, YotaPhone!" and start activity on Epd screen
mMainText.setText(getString(R.string.hello_yota_phone));
this.startActivity(new Intent(this, EpdActivity.class));
}
}
示例9: getView
import android.widget.TextView; //導入方法依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parentView) {
// Get the parts
menuItemLayout = (RelativeLayout) layoutInflater.inflate(R.layout.list_item_menu_drawer, parentView, false);
ImageView imageView = (ImageView) menuItemLayout.findViewById(R.id.menu_icon);
TextView textView = (TextView) menuItemLayout.findViewById(R.id.menu_title);
// Set the parts equal to the corresponding part
Drawable icon = activity.getResources().getDrawable(iconIdList[position]);
String title = titleList[position];
imageView.setImageDrawable(icon);
textView.setText(title);
// Set position as tag
menuItemLayout.setTag(position);
return menuItemLayout;
}
示例10: getView
import android.widget.TextView; //導入方法依賴的package包/類
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
if (convertView == null) {
convertView = inflate(getContext(), R.layout.tide_location_grid_item, null);
}
final TideLocations tideLocation = getItem(position);
ImageView tideLocationImageView = (ImageView) convertView.findViewById(R.id.tideLocationImage);
TextView tideLocationTextView = (TextView) convertView.findViewById(R.id.tideLocationName);
tideLocationImageView.setImageResource(tideLocation.getImageId());
tideLocationTextView.setText(tideLocation.getName());
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
getController().tideLocationSelected(tideLocation.getNoaaApiId(), tideLocation.getName());
}
});
return convertView;
}
示例11: setText
import android.widget.TextView; //導入方法依賴的package包/類
public static boolean setText(View view, int id, int text) {
TextView textView = (TextView) view.findViewById(id);
if (textView == null)
return false;
textView.setText(text);
return true;
}
示例12: onCreate
import android.widget.TextView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_security_tip_area);
headTv= (TextView) findViewById(R.id.securityAreaHead);
areaTv= (TextView) findViewById(R.id.securityAreaTv);
linkTv= (TextView) findViewById(R.id.securityAreaRefTv);
Intent intent= getIntent();
String name= intent.getStringExtra("name");
String data= intent.getStringExtra("data");
final String ref= intent.getStringExtra("ref");
headTv.setText(name);
areaTv.setText(data);
linkTv.setText(ref);
linkTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(ref.equals("None")){
return;
}
Uri uri = Uri.parse(ref);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, uri);
SecurityTipArea.this.startActivity(browserIntent);
}
});
}
示例13: setSpannableStr
import android.widget.TextView; //導入方法依賴的package包/類
public static void setSpannableStr(TextView textView, String str, int startIndex, int endIndex, float proporation) {
SpannableString spannableString = new SpannableString(str);
ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor("#393939"));
spannableString.setSpan(colorSpan, startIndex, endIndex, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
RelativeSizeSpan sizeSpan01 = new RelativeSizeSpan(proporation);
spannableString.setSpan(sizeSpan01, startIndex, endIndex, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
textView.setText(spannableString);
}
示例14: initBottom
import android.widget.TextView; //導入方法依賴的package包/類
private void initBottom(LinearLayout llBottom, float ratio) {
LinearLayout llAt = new LinearLayout(activity);
llAt.setPadding(0, 0, 0, 5);
llAt.setBackgroundColor(0xffffffff);
int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
llBottom.addView(llAt, lp);
tvAt = new TextView(activity);
tvAt.setTextColor(0xff3b3b3b);
tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
tvAt.setGravity(Gravity.BOTTOM);
tvAt.setText("@");
int padding = (int) (DESIGN_LEFT_PADDING * ratio);
tvAt.setPadding(padding, 0, padding, 0);
lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
llAt.addView(tvAt, lp);
tvAt.setOnClickListener(this);
if (isShowAtUserLayout(platform.getName())) {
tvAt.setVisibility(View.VISIBLE);
} else {
tvAt.setVisibility(View.INVISIBLE);
}
tvTextCouter = new TextView(activity);
tvTextCouter.setTextColor(0xff3b3b3b);
tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
onTextChanged(etContent.getText(), 0, 0, 0);
tvTextCouter.setPadding(padding, 0, padding, 0);
lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
lp.weight = 1;
llAt.addView(tvTextCouter, lp);
View v = new View(activity);
v.setBackgroundColor(0xffcccccc);
int px1 = ratio > 1 ? ((int) ratio) : 1;
lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px1);
llBottom.addView(v, lp);
}
示例15: displayFoundUser
import android.widget.TextView; //導入方法依賴的package包/類
private void displayFoundUser(final View view, final String name, final String email) {
if (view == null || name == null || name.equals("")) {
throw new IllegalArgumentException();
}
TableLayout table = (TableLayout) view.findViewById(R.id.table);
TableRow tableRow = new TableRow(this.getContext());
//tableRow.setBackgroundColor(getResources().getColor(R.color.colorAccent));
tableRow.setPadding(20, 20, 20, 5);
TableRow.LayoutParams layoutParams = new TableRow.LayoutParams();
layoutParams.setMargins(50, 40, 40, 40);
TextView nameTextView = new TextView(this.getContext());
nameTextView.setText(name);
nameTextView.setTextSize(22);
nameTextView.setTextColor(getResources().getColor(R.color.cast_expanded_controller_text_color));
nameTextView.setLayoutParams(layoutParams);
tableRow.addView(nameTextView);
tableRow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((SideBarActivity) getActivity()).searchViewAsMenuItem.collapseActionView();
listener.onDisplayProfileFragmentInteraction(name, email);
}
});
table.addView(tableRow);
}