本文整理了Java中android.widget.TextView.setId()
方法的一些代码示例,展示了TextView.setId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setId()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setId
暂无
代码示例来源:origin: stackoverflow.com
TextView tv1 = new TextView(this);
tv1.setId(1);
TextView tv2 = new TextView(this);
tv2.setId(2);
代码示例来源:origin: stackoverflow.com
RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.relativeLayout1);
TextView mTextView = new TextView(context);
mTextView.setText("Dynamic TextView");
mTextView.setId(111);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
mainLayout.addView(mTextView, params);
代码示例来源:origin: stackoverflow.com
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;
public class Stackoverflow extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
View linearLayout = findViewById(R.id.info);
//LinearLayout layout = (LinearLayout) findViewById(R.id.info);
TextView valueTV = new TextView(this);
valueTV.setText("hallo hallo");
valueTV.setId(5);
valueTV.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
((LinearLayout) linearLayout).addView(valueTV);
}
}
代码示例来源:origin: stackoverflow.com
for(int i = 0; i < 10; i++)
final TextView textView = new TextView(this);
textView.setText("Text "+i);
textView.setTextColor(rnd.nextInt() | 0xff000000);
textView.setId(curTextViewId);
final RelativeLayout.LayoutParams params =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,
代码示例来源:origin: stackoverflow.com
TextView t= new TextView(ctx);
t.setId(2);
t.setTextColor(Color.BLACK);
t.setText(DetailIds[bird]);
mLinearLayout.addView(t,params);
mLinearLayout.setBackgroundColor(Color.WHITE);
setContentView(mLinearLayout);
代码示例来源:origin: stackoverflow.com
TextView Label3 = new TextView(this);
Label3.setId(300);
Label3.setTextAppearance(this, android.R.attr.textAppearanceMedium);
Label3.setLayoutParams(labelParams);
Label3.setText("My textViewCaption:");
ll3.addView(Label3);
代码示例来源:origin: stackoverflow.com
RelativeLayout.LayoutParams params4 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
TextView tv1 = new TextView(this);
tv1.setId(1);
tv1.setText("textView1");
TextView tv2 = new TextView(this);
params2.addRule(RelativeLayout.RIGHT_OF, tv1.getId());
tv2.setId(2);
tv2.setText("textView2");
TextView tv3 = new TextView(this);
params3.addRule(RelativeLayout.BELOW, tv1.getId());
tv3.setId(3);
tv3.setText("textView3");
TextView tv4 = new TextView(this);
params4.addRule(RelativeLayout.RIGHT_OF, tv3.getId());
params4.addRule(RelativeLayout.ALIGN_BOTTOM, tv3.getId());
tv4.setId(4);
tv4.setText("textView4");
代码示例来源:origin: lygttpod/SuperTextView
/**
* 初始化textView
*
* @param textView 对象
* @param layoutParams 对象
* @param id id
* @param textColor 颜色值
* @param textSize 字体大小
* @return 返回
*/
public TextView initText(TextView textView, LayoutParams layoutParams, int id, int textColor, int textSize) {
if (textView == null) {
textView = new TextView(mContext);
textView.setId(id);
textView.setLayoutParams(layoutParams);
textView.setTextColor(textColor);
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
// textView.setGravity(Gravity.CENTER);
textView.setLines(mSetLines);
textView.setSingleLine(mSetSingleLine);
// textView.setMaxEms(mSetMaxEms);
// textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setFilters(new InputFilter[]{new InputFilter.LengthFilter(mSetMaxEms) });
addView(textView);
}
return textView;
}
代码示例来源:origin: stackoverflow.com
public class RL extends RelativeLayout {
public RL(Context context) {
super(context);
TextView first = new TextView(context);
TextView second = new TextView(context);
first.setText("First");
first.setId(1);
second.setText("Second");
second.setId(2);
RelativeLayout.LayoutParams lpSecond = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
addView(second, lpSecond);
RelativeLayout.LayoutParams lpFirst = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lpFirst.addRule(RelativeLayout.RIGHT_OF, second.getId());
addView(first, lpFirst);
}
}
代码示例来源:origin: stackoverflow.com
private TextView initializeTextView(final Resources resources) {
TextView text = new TextView(this.activity);
text.setId(TEXT_ID);
text.setText(this.text);
Typeface myTypeFace = Typeface.createFromAsset(this.activity.getAssets(), "gothamBold.ttf");
text.setTypeface(myTypeFace);
text.setGravity(this.style.gravity);
// set the text color if set
if (this.style.textColorResourceId != 0) {
text.setTextColor(resources.getColor(this.style.textColorResourceId));
}
代码示例来源:origin: stackoverflow.com
LinearLayout ll = (LinearLayout) findViewById(R.id.llexample);
for(int i=1;i<=11;i++){
TextView tv = new TextView(this); //create Text View
tv.setId(i); //then set the id to i
ll.addView(tv); //add TV to example Layout
}
代码示例来源:origin: stackoverflow.com
listLayout.setId(5000);
TextView listText = new TextView(MainActivity1.this);
listText.setId(5001);
listText.setText(super.getItem(position));
代码示例来源:origin: bingoogolapple/BGABanner-Android
indicatorLp.addRule(CENTER_VERTICAL);
if (mIsNumberIndicator) {
mNumberIndicatorTv = new TextView(context);
mNumberIndicatorTv.setId(R.id.banner_indicatorId);
mNumberIndicatorTv.setGravity(Gravity.CENTER_VERTICAL);
mNumberIndicatorTv.setSingleLine(true);
mTipTv = new TextView(context);
mTipTv.setGravity(Gravity.CENTER_VERTICAL);
mTipTv.setSingleLine(true);
代码示例来源:origin: stackoverflow.com
private View getHintView(Context context) {
if (mHintText != null && mHintText.length() > 0) {
final TextView hintView = (TextView) LayoutInflater.from(context).inflate(
mHintResource, null).findViewById(com.android.internal.R.id.text1);
hintView.setText(mHintText);
hintView.setId(HINT_VIEW_ID);
return hintView;
} else {
return null;
}
}
代码示例来源:origin: stackoverflow.com
LinearLayout header = (LinearLayout)findViewById(R.id.header);
TextView valueTV = new TextView(Schedule.this);
valueTV.setText("Event in Progress");
valueTV.setTextColor(Color.parseColor("#FFFFFF"));
valueTV.setTypeface(TypeFaceConstant.getOpensasItalic(getApplicationContext()));
valueTV.setId(0);
valueTV.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
valueTV.setGravity(Gravity.TOP);
valueTV.setPadding(20, 0, 0, 0);
header.addView(valueTV);
代码示例来源:origin: stackoverflow.com
private TextView createTextView(int vId) {
TextView textView = new TextView(this);
textView.setId(vId);
textView.setOnClickListener(myClickListener);
return textView;
}
代码示例来源:origin: jberkel/sms-backup-plus
private static Dialog getLogDialog(Context context, @NonNull File file) {
final int PAD = 5;
final TextView view = new TextView(context);
view.setId(ID);
view.setText(readLog(file));
final ScrollView scrollView = new ScrollView(context) {
{
addView(view);
setPadding(PAD, PAD, PAD, PAD);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
scrollTo(0, view.getHeight());
}
};
return new AlertDialog.Builder(context)
.setPositiveButton(android.R.string.ok, null)
.setTitle(file.getPath())
.setView(scrollView)
.create();
}
代码示例来源:origin: Bearded-Hen/Android-Bootstrap
TextView childView = new TextView(getContext());
childView.setGravity(Gravity.CENTER_VERTICAL);
childView.setLayoutParams(childParams);
childView.setText(text.replaceFirst(REPLACE_REGEX_HEADER, ""));
childView.setTextSize((baselineDropDownViewFontSize - 2F) * bootstrapSize);
childView.setClickable(false);
childView.setId(clickableChildCounter++);
childView.setText(text.replaceFirst(REPLACE_REGEX_DISABLED, ""));
childView.setText(text);
childView.setId(clickableChildCounter++);
代码示例来源:origin: stackoverflow.com
LayoutInflater inflater = getLayoutInflater();
for (int rowID = 0; rowID < 15; rowID++) {
TableRow row = (TableRow)inflater.inflate(R.id.tablerow, tl, false);
TextView content = (TextView)row.findViewById(R.id.content);
content.setId(rowID);
content.setText("this is the content");
tl.addView(row);
}
代码示例来源:origin: stackoverflow.com
TextView tv=new TextView(context);
tv.setBackgroundResource(R.drawable.textview_bg);
tv.setPadding(20, 5, 40, 5);
tv.setText("set your text");
tv.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
tv.setTextColor(Color.RED);
tv.setClickable(true);
tv.setId(id);//where id is an integer which should be unique for each TextView
layout.addView(tv);
内容来源于网络,如有侵权,请联系作者删除!