List of usage examples for android.widget TextView setBackgroundResource
@RemotableViewMethod public void setBackgroundResource(@DrawableRes int resid)
From source file:com.android.messaging.ui.ViewPagerTabs.java
private void addTab(CharSequence tabTitle, final int position) { final TextView textView = new TextView(getContext()); textView.setText(tabTitle);//w w w .j a va2 s. c o m textView.setBackgroundResource(R.drawable.contact_picker_tab_background_selector); textView.setGravity(Gravity.CENTER); textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPager.setCurrentItem(getRtlPosition(position)); } }); // Assign various text appearance related attributes to child views. if (mTextStyle > 0) { textView.setTypeface(textView.getTypeface(), mTextStyle); } if (mTextSize > 0) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); } if (mTextColor != null) { textView.setTextColor(mTextColor); } textView.setAllCaps(mTextAllCaps); textView.setPadding(mSidePadding, 0, mSidePadding, 0); mTabStrip.addView(textView, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1)); // Default to the first child being selected if (position == 0) { mPrevSelected = 0; textView.setSelected(true); } }
From source file:com.cytmxk.test.animation.ViewPagerTabs.java
private void addTab(CharSequence tabTitle, final int position) { View tabView;//from w w w .ja va 2 s . co m if (mTabIcons != null && position < mTabIcons.length) { View iconView = new View(getContext()); iconView.setBackgroundResource(mTabIcons[position]); iconView.setContentDescription(tabTitle); tabView = iconView; } else { final TextView textView = new TextView(getContext()); textView.setText(tabTitle); textView.setBackgroundResource(R.drawable.view_pager_tab_background); // Assign various text appearance related attributes to child views. if (mTextStyle > 0) { textView.setTypeface(textView.getTypeface(), mTextStyle); } if (mTextSize > 0) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); } if (mTextColor != null) { textView.setTextColor(mTextColor); } textView.setAllCaps(mTextAllCaps); textView.setGravity(Gravity.CENTER); tabView = textView; } tabView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPager.setCurrentItem(getRtlPosition(position)); } }); tabView.setOnLongClickListener(new OnTabLongClickListener(position)); tabView.setPadding(mSidePadding, 0, mSidePadding, 0); mTabStrip.addView(tabView, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1)); // Default to the first child being selected if (position == 0) { mPrevSelected = 0; tabView.setSelected(true); } }
From source file:com.zhongsou.souyue.ui.indicator.CheckTabPageIndicator.java
private void doSetTextStyle(TextView tv, int background) { tv.setGravity(Gravity.CENTER);/*w ww . j a v a2 s .c o m*/ tv.setBackgroundResource(background); tv.setPadding(10, 12, 10, 12); tv.setTextSize(16); tv.setMaxLines(1); tv.setWidth(dip2px(this.getContext(), 110)); tv.setTextColor(0xff696969); }
From source file:com.jaspersoft.android.jaspermobile.widget.DraggableViewsContainer.java
private void showTextInputDialog(int viewId) { final AnnotationInputDialog annotationInputDialog = new AnnotationInputDialog(getContext()); annotationInputDialog.setTitle(getContext().getString(R.string.annotation_add_note)); annotationInputDialog.setId(viewId); annotationInputDialog.setValue(""); annotationInputDialog.setOnEventListener(new AnnotationInputDialog.OnAnnotationInputListener() { @Override/* w w w . j av a 2s .c om*/ public void onAnnotationEntered(int id, String inputText) { TextView note = (TextView) findViewById(id); note.setText(inputText); if (mNeedsBorder) { note.setBackgroundResource(R.drawable.bg_annotation_text_border); note.getBackground().setColorFilter(mColor, PorterDuff.Mode.MULTIPLY); int borderPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, BORDER_PADDING, getContext().getResources().getDisplayMetrics()); note.setPadding(borderPadding, borderPadding, borderPadding, borderPadding); } analytics.sendEvent(Analytics.EventCategory.RESOURCE.getValue(), Analytics.EventAction.ANNOTATED.getValue(), Analytics.EventLabel.WITH_TEXT.getValue()); } @Override public void onAnnotationCanceled(int id) { TextView noteView = (TextView) findViewById(id); removeView(noteView); } }); annotationInputDialog.show(); }
From source file:com.yojiokisoft.yumekanow.activity.MainActivity.java
/** * ????????./*w w w .jav a2 s . com*/ * * @param width * @param height * @param title * @return */ private TextView getTabView(int width, int height, String title) { TextView view = new TextView(this); view.setMinimumWidth(width); view.setMinimumHeight(height); view.setGravity(Gravity.CENTER); view.setBackgroundResource(R.drawable.tab_indicator_holo); view.setText(title); return view; }
From source file:com.app.jdy.adapter.MyOrderAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null || convertView.getTag() == null) { // ?list_item convertView = listContainer.inflate(this.itemViewResource, null); TextView my_order_time = (TextView) convertView.findViewById(R.id.my_order_time); TextView my_order_name = (TextView) convertView.findViewById(R.id.my_order_name); TextView my_order_momey = (TextView) convertView.findViewById(R.id.my_order_momey); if (position % 2.0 == 0) { my_order_time.setBackgroundResource(R.drawable.item_color); my_order_name.setBackgroundResource(R.drawable.item_color); my_order_momey.setBackgroundResource(R.drawable.item_color); }/*from w w w. j av a 2 s. c o m*/ my_order_name.setText(list.get(position).getName()); my_order_momey.setText("+" + list.get(position).getMoney()); my_order_time.setText(changeTime(list.get(position).getTime())); } return convertView; }
From source file:com.app.jdy.adapter.FaceValueAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null || convertView.getTag() == null) { // ?list_item convertView = listContainer.inflate(this.itemViewResource, null); TextView face_user_time = (TextView) convertView.findViewById(R.id.face_user_time); TextView face_user_name = (TextView) convertView.findViewById(R.id.face_user_name); TextView face_user_momey = (TextView) convertView.findViewById(R.id.face_user_momey); if (position % 2.0 == 0) { face_user_time.setBackgroundResource(R.drawable.item_color); face_user_name.setBackgroundResource(R.drawable.item_color); face_user_momey.setBackgroundResource(R.drawable.item_color); }// w w w. j a v a2 s. c o m face_user_name.setText(list.get(position).getName()); face_user_momey.setText("+" + list.get(position).getMoney()); face_user_time.setText(changeTime(list.get(position).getTime())); } return convertView; }
From source file:com.app.jdy.adapter.MyRecordAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null || convertView.getTag() == null) { // ?list_item convertView = listContainer.inflate(this.itemViewResource, null); TextView my_record_money = (TextView) convertView.findViewById(R.id.my_order_name); TextView my_record_time = (TextView) convertView.findViewById(R.id.my_order_momey); TextView my_record_message = (TextView) convertView.findViewById(R.id.my_order_time); if (position % 2.0 == 0) { my_record_money.setBackgroundResource(R.drawable.item_color); my_record_time.setBackgroundResource(R.drawable.item_color); my_record_message.setBackgroundResource(R.drawable.item_color); }/* w w w . j a v a2 s .c o m*/ my_record_money.setText("+" + list.get(position).getMoney()); my_record_time.setText(changeTime(list.get(position).getDopositeTime())); my_record_message.setText(list.get(position).getMessage()); } return convertView; }
From source file:gov.sfmta.sfpark.DetailViewActivity.java
public TextView highlightText(String val) { TextView gtv = normalText(val); gtv.setBackgroundResource(R.color.highlight_row); return gtv;//ww w . ja va 2s . com }
From source file:de.fahrgemeinschaft.util.ReoccuringWeekDaysView.java
private TextView makeRecurringDayButton(Context ctx) { TextView day = new UnScrollingTextView(ctx); if (clickable) day.setOnClickListener(toggleSelectedState); LayoutParams lp = new LayoutParams(0, LayoutParams.MATCH_PARENT); lp.weight = 1;/*w w w .j a v a 2 s.co m*/ day.setLayoutParams(lp); day.setTextAppearance(getContext(), R.style.dark_Bold); day.setBackgroundResource(R.drawable.btn_night); day.setGravity(Gravity.CENTER); day.setFocusable(true); return day; }