本文整理汇总了Java中android.widget.CheckedTextView.setCompoundDrawablesWithIntrinsicBounds方法的典型用法代码示例。如果您正苦于以下问题:Java CheckedTextView.setCompoundDrawablesWithIntrinsicBounds方法的具体用法?Java CheckedTextView.setCompoundDrawablesWithIntrinsicBounds怎么用?Java CheckedTextView.setCompoundDrawablesWithIntrinsicBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.CheckedTextView
的用法示例。
在下文中一共展示了CheckedTextView.setCompoundDrawablesWithIntrinsicBounds方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setBusy
import android.widget.CheckedTextView; //导入方法依赖的package包/类
public void setBusy(boolean busy, AbsListView view) {
mBusy = busy;
if(!mBusy) {
Resources r = mContext.getResources();
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 48, r.getDisplayMetrics());
int first = view.getFirstVisiblePosition();
int count = view.getChildCount();
for (int i=0; i<count; i++) {
CheckedTextView t = (CheckedTextView)view.getChildAt(i);
if (t.getTag() != null) {
ResolveInfo ri = mData.get(first+i);
Drawable d = ri.loadIcon(mPackageManager);
//only replace the icons that were too large
if(d.getIntrinsicHeight() > px) {
Log.d(getClass().getSimpleName(), String.format("RESIZING icon => %d us => %s", d.getIntrinsicHeight(), px));
d = resize(r, d, (int) px);
t.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null);
}
//t.setTag(null);
}
}
}
}
示例2: getView
import android.widget.CheckedTextView; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
CheckedTextView tv = (CheckedTextView) super.getView(position, convertView, parent);
if (position == 0) {
tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_bg_trans, 0, 0, 0);
} else {
tv.setCompoundDrawablesWithIntrinsicBounds(mPlayers.get(position - 1).icon, null, null, null);
}
return tv;
}
示例3: getView
import android.widget.CheckedTextView; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
CheckedTextView tv = (CheckedTextView) super.getView(position, convertView, parent);
tv.setCompoundDrawablesWithIntrinsicBounds(mIcons.getDrawable(position), null, null, null);
mListView.setItemChecked(position, mCheckedItems[position]);
return tv;
}
示例4: initUi
import android.widget.CheckedTextView; //导入方法依赖的package包/类
private void initUi() {
followCheckedText = new CheckedTextView(getActivity());
try {
followCheckedText.setBackgroundColor(getActivity().getResources().getColor(android.R.color.white));
} catch (Throwable t) {
Log.w(TAG, t);
}
followCheckedText.setChecked(true);
int dp_10 = com.mob.tools.utils.R.dipToPx(getActivity(), 10);
followCheckedText.setCompoundDrawablePadding(dp_10);
followCheckedText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.bg_checkbox, 0, 0, 0);
followCheckedText.setGravity(Gravity.CENTER_VERTICAL);
followCheckedText.setPadding(dp_10, dp_10, dp_10, dp_10);
followCheckedText.setText(R.string.follow_us);
followCheckedText.setTextColor(0xff909090);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
followCheckedText.setLayoutParams(lp);
LinearLayout llBody = (LinearLayout) getBodyView().getChildAt(0);
llBody.addView(followCheckedText);
followCheckedText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CheckedTextView ctv = (CheckedTextView) v;
ctv.setChecked(!ctv.isChecked());
}
});
followCheckedText.measure(0, 0);
int height = followCheckedText.getMeasuredHeight();
TranslateAnimation animShow = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0,
Animation.ABSOLUTE, height,
Animation.ABSOLUTE, 0);
animShow.setDuration(1000);
getWebBody().startAnimation(animShow);
followCheckedText.startAnimation(animShow);
}
示例5: getView
import android.widget.CheckedTextView; //导入方法依赖的package包/类
public View getView(int position, View view, ViewGroup parent) {
if (view == null) {
LayoutInflater inflater = getLayoutInflater();
view = inflater.inflate(android.R.layout.simple_list_item_multiple_choice, null, true);
}
CheckedTextView checkedTextView = (CheckedTextView) view;
checkedTextView.setText(apps[position].name);
checkedTextView.setCompoundDrawablesWithIntrinsicBounds(apps[position].icon, null, null, null);
checkedTextView.setCompoundDrawablePadding((int) (8 * getResources().getDisplayMetrics().density));
return view;
}
示例6: initUi
import android.widget.CheckedTextView; //导入方法依赖的package包/类
private void initUi(String platName) {
ctvFollow = new CheckedTextView(getActivity());
try {
ctvFollow.setBackgroundResource(R.drawable.auth_follow_bg);
} catch (Throwable t) {
t.printStackTrace();
}
ctvFollow.setChecked(true);
int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getActivity(), 10);
ctvFollow.setCompoundDrawablePadding(dp_10);
ctvFollow.setCompoundDrawablesWithIntrinsicBounds(R.drawable.auth_cb, 0, 0, 0);
ctvFollow.setGravity(Gravity.CENTER_VERTICAL);
ctvFollow.setPadding(dp_10, dp_10, dp_10, dp_10);
ctvFollow.setText(R.string.sm_item_fl_weibo);
if (platName.equals("TencentWeibo")) {
ctvFollow.setText(R.string.sm_item_fl_tc);
}
ctvFollow.setTextColor(0xff909090);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
ctvFollow.setLayoutParams(lp);
LinearLayout llBody = (LinearLayout) getBodyView().getChildAt(0);
llBody.addView(ctvFollow);
ctvFollow.setOnClickListener(this);
ctvFollow.measure(0, 0);
int height = ctvFollow.getMeasuredHeight();
TranslateAnimation animShow = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0,
Animation.ABSOLUTE, height,
Animation.ABSOLUTE, 0);
animShow.setDuration(1000);
getWebBody().startAnimation(animShow);
ctvFollow.startAnimation(animShow);
}
示例7: init
import android.widget.CheckedTextView; //导入方法依赖的package包/类
/**
* 初始化控件
*/
private void init(final Context context) {
this.setOrientation(LinearLayout.HORIZONTAL);
this.setBackgroundResource(R.drawable.index_bottom_bar);
LayoutInflater inflater = LayoutInflater.from(context);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
params.weight = 1.0f;
params.gravity = Gravity.CENTER;
mCheckedList.clear();
int size = mLabels.length;
for (int i = 0; i < size; i++) {
final int index = i;
// 每个tab对应的layout
final View view = inflater.inflate(R.layout.tab_item, null);
final CheckedTextView itemName = (CheckedTextView) view
.findViewById(R.id.item_name);
ImageView imageView = (ImageView) view.findViewById(R.id.iv_bg);
if(i == 2) {
itemName.setVisibility(GONE);
imageView.setVisibility(VISIBLE);
imageView.setImageResource(mIconTa.getResourceId(i, 0));
this.addView(view,params);
// 将各个tab的View添加到list
mViewList.add(view);
}else {
itemName.setCompoundDrawablesWithIntrinsicBounds(null, context
.getResources().getDrawable(mIconTa.getResourceId(i, 0)), null, null);
itemName.setText(mLabels[i]);
itemName.setTextColor(mTextColorStateList);
// 指示点ImageView,如有版本更新需要显示
final TextView indicateImg = (TextView) view
.findViewById(R.id.tv_message_indicator);
this.addView(view, params);
// 将CheckedTextView添加到list中,便于操作
mCheckedList.add(itemName);
// 将指示图片加到list,便于控制显示隐藏
mMessageIndicate.add(indicateImg);
// 将各个tab的View添加到list
mViewList.add(view);
}
// CheckedTextView设置索引作为tag,以便后续更改颜色、图片等
itemName.setTag(index);
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// 设置底部图片和文字的显示
setTabsDisplay(index);
if (null != mTabListener) {
// tab项被选中的回调事件
mTabListener.onTabSelected(index);
}
}
});
// 初始化 底部菜单选中状态,默认第一个选中
if (i == 0&&i!=2) {
itemName.setChecked(true);
} else if(i!=2){
itemName.setChecked(false);
}
}
}
示例8: getView
import android.widget.CheckedTextView; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if( view == null ){
//We must create a View:
LayoutInflater inflater=act.getLayoutInflater();
view = inflater.inflate(R.layout.custom_row, parent, false);
}
CheckedTextView temp = (CheckedTextView) view.findViewById(R.id.text1);
Drawable dr = null;
Bitmap bitmap = null;
Drawable d = null;
if (position == 0) {
temp.setText(water);
dr = getResources().getDrawable(R.drawable.potboil);
bitmap = ((BitmapDrawable) dr).getBitmap();
// Scale it to 67 x 67
d = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(bitmap, 67, 67, true));
} else if (position == 1) {
temp.setText(microDone);
dr = getResources().getDrawable(R.drawable.microdone);
bitmap = ((BitmapDrawable) dr).getBitmap();
// Scale it to 100 x 67
d = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(bitmap, 100, 67, true));
} else if (position == 2) {
temp.setText(microExplo);
dr = getResources().getDrawable(R.drawable.microexplo);
bitmap = ((BitmapDrawable) dr).getBitmap();
// Scale it to 100 x 67
d = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(bitmap,100, 67, true));
}
temp.setCompoundDrawablesWithIntrinsicBounds(null, null, d, null);
if ((position == 0 && TabActivity.tasksToSelected.get(water)) ||
(position == 1 && TabActivity.tasksToSelected.get(microDone)) ||
(position == 2 && TabActivity.tasksToSelected.get(microExplo))) {
view.setBackgroundColor(Color.parseColor(green));
} else {
view.setBackgroundColor(Color.parseColor(gray));
}
adapter.notifyDataSetChanged();
return view;
}
示例9: getView
import android.widget.CheckedTextView; //导入方法依赖的package包/类
/**
* Get current visible item. Usually this is called only when the spinner is created.
*/
@Override
public View getView(int position, View convertView, ViewGroup parent){
View row;
LayoutInflater inflater = context.getLayoutInflater();
row = inflater.inflate(R.layout.spinner_categ_item, parent, false);
if (parent.getChildCount() > 0 || Fragment_NewIssueA.spPosition != -1) {
Category item = data.get(position);
// Parse the data from each object and set it.
if(item != null){
ImageView cat_imv = (ImageView) row.findViewById(R.id.categIcon);
CheckedTextView cat_tv = (CheckedTextView) row.findViewById(R.id.categName);
cat_tv.setCheckMarkDrawable(null);
if(cat_imv != null && item._icon!=null){
Bitmap bmicon = BitmapFactory.decodeByteArray(item._icon, 0, item._icon.length);
if (item._level == 2)
bmicon = Bitmap.createScaledBitmap(bmicon, (int) (45 * dens + 0.5f), (int) (50 * dens + 0.5f), true);
else
bmicon = Bitmap.createScaledBitmap(bmicon, (int) (50 * dens + 0.5f), (int) (55 * dens + 0.5f), true);
cat_tv.setCompoundDrawablesWithIntrinsicBounds(new BitmapDrawable(bmicon), null, null, null);
} else {
cat_tv.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
}
cat_tv.setCompoundDrawablePadding(20);
if(cat_tv != null){
cat_tv.setText(item._name);
cat_tv.setTextSize(15);
}
}
} else { // Before appearance of the Spinner
((CheckedTextView)row.findViewById(R.id.categName)).setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
}
return row;
}