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

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

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

TextView.setText介绍

暂无

代码示例

代码示例来源:origin: scwang90/SmartRefreshLayout

protected TextView createMaskView(Context context, String text, int textSize, int gravity) {
  final TextView maskView = new TextView(context);
  maskView.setTextColor(Color.BLACK);
  maskView.setGravity(gravity | Gravity.CENTER_HORIZONTAL);
  maskView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
  maskView.setText(text);
  //noinspection UnnecessaryLocalVariable
  final View view = maskView;
  view.setBackgroundColor(Color.WHITE);
  return maskView;
}

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

TextView textView = new TextView(this);
textView.setText(R.string.register);

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

private void updateView(int index){
  View v = yourListView.getChildAt(index - 
    yourListView.getFirstVisiblePosition());

  if(v == null)
    return;

  TextView someText = (TextView) v.findViewById(R.id.sometextview);
  someText.setText("Hi! I updated you manually!");
}

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

AlertDialog.Builder builder;
AlertDialog alertDialog;

Context mContext = getApplicationContext();
LayoutInflater inflater = (LayoutInflater)
    mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_dialog,
    (ViewGroup) findViewById(R.id.layout_root));

TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("Hello, this is a custom dialog!");
ImageView image = (ImageView) layout.findViewById(R.id.image);
image.setImageResource(R.drawable.android);

builder = new AlertDialog.Builder(mContext);
builder.setView(layout);
alertDialog = builder.create();

代码示例来源:origin: cSploit/android

mScanReceiver = new ScanReceiver();
mConnectionReceiver = new ConnectionReceiver();
mStatusText = (TextView) v.findViewById(R.id.scanStatusText);
mAdapter = new ScanAdapter();
mKeyList = new ArrayList<>();
mStatusText.setText( getString(R.string.wifi_initializing) );
  mStatusText.setText( getString(R.string.wifi_activating_iface) );
  mWifiManager.setWifiEnabled(true);
  mStatusText.setText(getString(R.string.wifi_activated));
mStatusText.setText( getString(R.string.wifi_scanning) );
mScanning = true;

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

intent.putParcelableArrayListExtra("files", new ArrayList<File>(Arrays.asList(files)));
  startService(intent);
bar.setProgress(file.progress);
TextView tv = (TextView) v.findViewById(R.id.textView);
tv.setText(file.toString());
v.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
  mEcs = new ExecutorCompletionService<NoResultType>(mExec);
  mBroadcastManager = LocalBroadcastManager.getInstance(this);
  mTasks = new ArrayList<MainActivity.DownloadingService.DownloadTask>();

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

LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = vi.inflate(R.layout.your_layout, null);

// fill in any details dynamically here
TextView textView = (TextView) v.findViewById(R.id.a_text_view);
textView.setText("your text");

// insert into main view
ViewGroup insertPoint = (ViewGroup) findViewById(R.id.insert_point);
insertPoint.addView(v, 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

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

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class FirstActivity extends RootActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    TextView tv = (TextView) findViewById(R.id.tvTitle);
    tv.setText("First Activity");
    Button bt = (Button) findViewById(R.id.buttonNext);
    bt.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        Intent i = new Intent(FirstActivity.this, SecondActivity.class);
        startActivity(i);

      }
    });
  }

}

代码示例来源:origin: TeamNewPipe/NewPipe

private View addItemView(final String title, @DrawableRes final int icon, ViewGroup container) {
  final View itemRoot = View.inflate(getContext(), R.layout.subscription_import_export_item, null);
  final TextView titleView = itemRoot.findViewById(android.R.id.text1);
  final ImageView iconView = itemRoot.findViewById(android.R.id.icon1);
  titleView.setText(title);
  iconView.setImageResource(icon);
  container.addView(itemRoot);
  return itemRoot;
}

代码示例来源:origin: vinc3m1/RoundedImageView

@Override
 public View getView(int position, View convertView, ViewGroup parent) {
  ViewGroup view;
  if (convertView == null) {
   view = (ViewGroup) mInflater.inflate(R.layout.rounded_item, parent, false);
  } else {
   view = (ViewGroup) convertView;
  }
  ColorItem item = getItem(position);
  ((ImageView) view.findViewById(R.id.imageView1)).setImageResource(item.mResId);
  ((ImageView) view.findViewById(R.id.imageView1)).setScaleType(item.mScaleType);
  ((TextView) view.findViewById(R.id.textView1)).setText(item.mLine1);
  ((TextView) view.findViewById(R.id.textView2)).setText(item.mLine2);
  ((TextView) view.findViewById(R.id.textView3)).setText(item.mScaleType.toString());
  return view;
 }
}

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

LayoutParams lparams = new LayoutParams(
  LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
TextView tv=new TextView(this);
tv.setLayoutParams(lparams);
tv.setText("test");
this.m_vwJokeLayout.addView(tv);

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

TableLayout table = new TableLayout(this);
TableRow tr = new TableRow(this);
tr.setBackgroundColor(Color.BLACK);
tr.setPadding(0, 0, 0, 2); //Border between rows

TableRow.LayoutParams llp = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
llp.setMargins(0, 0, 2, 0);//2px right-margin

//New Cell
LinearLayout cell = new LinearLayout(this);
cell.setBackgroundColor(Color.WHITE);
cell.setLayoutParams(llp);//2px border on the right for the cell

TextView tv = new TextView(this);
tv.setText("Some Text");
tv.setPadding(0, 0, 4, 3);

cell.addView(tv);
tr.addView(cell);
//add as many cells you want to a row, using the same approach

table.addView(tr);

代码示例来源:origin: square/picasso

@Override public View getView(int position, View convertView, ViewGroup parent) {
  TextView view = (TextView) convertView;
  if (view == null) {
   view = (TextView) inflater.inflate(R.layout.picasso_sample_activity_item, parent, false);
  }

  view.setText(getItem(position).name);

  return view;
 }
}

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

TextView txtName = (TextView) convertView.findViewById(R.id.nameEdit);
txtName.setText(score.getName());
Button b = (Button)convertView.findViewById(R.id.deletePlayer);
b.setTag(position);
b.setOnClickListener(new View.OnClickListener() {
     public void onClick(View v) {

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

findViewById(R.id.btn_back).setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
findViewById(R.id.btn_forward).setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
if(text != null) mTextView.setText(text);

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

public View getView(int position, View convertView, ViewGroup parent){
   // TODO Auto-generated method stub
   View v;
   if(convertView==null)
   {
     LayoutInflater li = getLayoutInflater();
     v = li.inflate(R.layout.icontext, null);
   }else{
     v = convertView;
   }
   TextView tv = (TextView)v.findViewById(R.id.icon_text);
   tv.setText(providers[position]);
   ImageView iv = (ImageView)v.findViewById(R.id.icon_image);
   iv.setImageResource(R.drawable.icon);
   return v;
 }

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

@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fr_simple_card, null);
    TextView card_title_tv = (TextView) v.findViewById(R.id.card_title_tv);
    card_title_tv.setText(mTitle);

    return v;
  }
}

代码示例来源:origin: hackware1993/MagicIndicator

@Override
public Object instantiateItem(ViewGroup container, int position) {
  TextView textView = new TextView(container.getContext());
  textView.setText(mDataList.get(position));
  textView.setGravity(Gravity.CENTER);
  textView.setTextColor(Color.BLACK);
  textView.setTextSize(24);
  container.addView(textView);
  return textView;
}

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

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class SecondActivity extends RootActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    TextView tv = (TextView) findViewById(R.id.tvTitle);
    tv.setText("Second Activity");
    Button bt = (Button) findViewById(R.id.buttonNext);
    bt.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        Intent i = new Intent(SecondActivity.this, ThirdActivity.class);
        startActivity(i);

      }
    });

  }

}

代码示例来源:origin: chentao0707/SimplifyReader

public void showNetworkError(View.OnClickListener onClickListener) {
  View layout = helper.inflate(R.layout.message);
  TextView textView = (TextView) layout.findViewById(R.id.message_info);
  textView.setText(helper.getContext().getResources().getString(R.string.common_no_network_msg));
  ImageView imageView = (ImageView) layout.findViewById(R.id.message_icon);
  imageView.setImageResource(R.drawable.ic_exception);
  if (null != onClickListener) {
    layout.setOnClickListener(onClickListener);
  }
  helper.showLayout(layout);
}

相关文章

TextView类方法