当前位置: 首页>>代码示例>>Java>>正文


Java TextView.setText方法代码示例

本文整理汇总了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);
       }
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:24,代码来源:AmountPicker.java

示例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;
}
 
开发者ID:bricam,项目名称:wordstack,代码行数:19,代码来源:MainActivity.java

示例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));

    }
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:20,代码来源:MainSheetsController.java

示例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;
}
 
开发者ID:vipycm,项目名称:mao-android,代码行数:18,代码来源:BillingFragment.java

示例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);
	}
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:14,代码来源:ConfigSyncActivity.java

示例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;
}
 
开发者ID:axlecho,项目名称:tuxguitar,代码行数:25,代码来源:TGBrowserSettingsFolderAdapter.java

示例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;
}
 
开发者ID:yimiaoxiehou,项目名称:ZhuHaiBusApplication,代码行数:18,代码来源:ActAdapter.java

示例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));
    }
}
 
开发者ID:yotadevices,项目名称:SDK-Samples,代码行数:19,代码来源:MainActivity.java

示例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;
}
 
开发者ID:Davarco,项目名称:Divertio,代码行数:19,代码来源:MenuDrawerAdapter.java

示例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;
}
 
开发者ID:bangarharshit,项目名称:ConductorMVP,代码行数:21,代码来源:TideLocationsView.java

示例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;
}
 
开发者ID:DyncKathline,项目名称:LiveGiftLayout,代码行数:9,代码来源:FileUtil.java

示例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);
        }
    });

}
 
开发者ID:shivam301296,项目名称:True-Weather,代码行数:32,代码来源:SecurityTipArea.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:Utils.java

示例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);
}
 
开发者ID:Leavessilent,项目名称:QuanMinTV,代码行数:41,代码来源:EditPagePort.java

示例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);
}
 
开发者ID:IrrilevantHappyLlamas,项目名称:Runnest,代码行数:31,代码来源:DisplayUserFragment.java


注:本文中的android.widget.TextView.setText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。