本文整理匯總了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;
}