下面列出了android.view.View#setEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void updateViewEnable(boolean enable, ViewGroup... parent) {
if (parent != null && parent.length > 0) {
for (ViewGroup group : parent) {
int len = group.getChildCount();
for (int j = 0; j < len; j++) {
View subView = group.getChildAt(j);
if (subView instanceof ViewGroup) {
updateViewEnable(enable, (ViewGroup) subView);
} else {
if (subView instanceof X8FixedEditText) {
subView.setEnabled(false);
} else {
subView.setEnabled(enable);
}
if (enable) {
subView.setAlpha(1.0f);
} else {
subView.setAlpha(0.6f);
}
}
}
}
}
}
public static void setEnabled(View view, boolean enabled)
{
if (view == null)
{
return;
}
view.setEnabled(enabled);
if (view instanceof ViewGroup)
{
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++)
{
setEnabled(viewGroup.getChildAt(i), enabled);
}
}
}
/**
* Called each {@link #transformPage(android.view.View, float)} before {{@link #onTransform(android.view.View, float)}.
* <p>
* The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
* not modify the same page properties. For instance changing from a transformation that applies rotation to a
* transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
* alpha.
*
* @param page
* Apply the transformation to this page
* @param position
* Position of page relative to the current front-and-center position of the pager. 0 is front and
* center. 1 is one full page position to the right, and -1 is one page position to the left.
*/
protected void onPreTransform(View page, float position) {
final float width = page.getWidth();
page.setRotationX(0);
page.setRotationY(0);
page.setRotation(0);
page.setScaleX(1);
page.setScaleY(1);
page.setPivotX(0);
page.setPivotY(0);
page.setTranslationY(0);
page.setTranslationX(isPagingEnabled() ? 0f : -width * position);
if (hideOffscreenPages()) {
page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
page.setEnabled(false);
} else {
page.setEnabled(true);
page.setAlpha(1f);
}
}
private void backViewAnimation(View oldView) {
oldView.startAnimation(FlyBackAnimation);
waitBar.startAnimation(FadeOutAnimation);
waitBar.setAlpha(0);
waitBar.setVisibility(View.GONE);
oldView.setEnabled(true);
}
private void setViewEnabled(boolean enabled, View... views) {
for(View view: views) {
view.setEnabled(enabled);
/*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB*//* && !(view instanceof SeekBar)*//*) {
if(enabled) {
view.setAlpha(ENABLED_ALPHA);
} else {
view.setAlpha(DISABLED_ALPHA);
}
}*/
}
}
private void setupCopyrightView(SlobDescriptor desc, boolean available, View view) {
View copyrightRow= view.findViewById(R.id.dictionary_copyright_row);
ImageView copyrightIcon = (ImageView) view.findViewById(R.id.dictionary_copyright_icon);
copyrightIcon.setImageDrawable(IconMaker.text(context, IconMaker.IC_COPYRIGHT));
TextView copyrightView = (TextView) view.findViewById(R.id.dictionary_copyright);
String copyright = desc.tags.get("copyright");
copyrightView.setText(copyright);
copyrightRow.setVisibility(Util.isBlank(copyright) ? View.GONE : View.VISIBLE);
copyrightRow.setEnabled(available);
}
@Override
protected void onButtonClick(View button) {
new DownloadManager(activity).cancel(app.getPackageName());
button.setVisibility(View.GONE);
View buttonDownload = activity.findViewById(R.id.download);
if (buttonDownload instanceof android.widget.Button) {
((android.widget.Button) buttonDownload).setText(R.string.details_download);
}
buttonDownload.setEnabled(true);
}
public static void setButtonEnabled(Context context, View b, boolean isEnabled)
{
@AttrRes int resId = isEnabled ? R.attr.colorButtonEnabled : R.attr.colorButtonDisabled;
b.setEnabled(isEnabled);
if (b instanceof AppCompatImageButton)
{
Utils.setImageButtonColorAttr(context, (AppCompatImageButton) b, resId);
}
if (b instanceof AppCompatButton)
{
((AppCompatButton) b).setTextColor(Utils.getThemeColorAttr(context, resId));
}
}
public static void disableViews(View... views) {
for (View view : views) {
if (view != null) {
view.setEnabled(false);
view.setVisibility(View.INVISIBLE);
}
}
}
private void refreshGCMEntries() {
GcmRegistrationManager gcmRegistrationManager = Matrix.getInstance(this).getSharedGcmRegistrationManager();
final CheckBox gcmBox = (CheckBox) findViewById(R.id.checkbox_useGcm);
gcmBox.setChecked(gcmRegistrationManager.useGCM() && gcmRegistrationManager.is3rdPartyServerRegistred());
// check if the GCM registration has not been rejected.
boolean gcmButEnabled = gcmRegistrationManager.useGCM() || gcmRegistrationManager.isGCMRegistred();
View parentView = (View)gcmBox.getParent();
parentView.setEnabled(gcmButEnabled);
gcmBox.setEnabled(gcmButEnabled);
parentView.setAlpha(gcmButEnabled ? 1.0f : 0.5f);
}
public static void enableViews(View... views) {
for (View view : views) {
if (view != null) {
view.setEnabled(true);
view.setVisibility(View.VISIBLE);
}
}
}
private View getViewForBlurb(String daBlurb, View view) {
TextView daBlurbTV = (TextView) view.findViewById(R.id.home_away_blurb_tv);
daBlurbTV.setText(String.valueOf(daBlurb));
view.setEnabled(false);
return view;
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.bt_notify_all_msgs:
startActivity(new Intent(this, NotifyListActivity.class));
break;
case R.id.bt_login:
BroadcastUtil.sendBroadcast(this, BroadcastUtil.APN_ACTION_RECONNECT);
v.setEnabled(false);
default:
break;
}
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.button_quit:
view.setEnabled(false);
System.exit(0);
}
}
@Override
public void onClick(View v) {
v.setEnabled(false);
MyHomePageUpTask task = new MyHomePageUpTask(adapter);
task.execute();
}
private void disableBottomButtonNavigation(View button) {
button.setAlpha(style.alphaOfDisabledElements);
button.setEnabled(false);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
// Get the decoration for the current row
Decoration decoration = mDecorationCursor.getDecoration();
RelativeLayout itemLayout = (RelativeLayout) view.findViewById(R.id.listitem);
// Set up the text view
ImageView itemImageView = (ImageView) view.findViewById(R.id.item_image);
TextView decorationNameTextView = (TextView) view.findViewById(R.id.item);
TextView skill1TextView = (TextView) view.findViewById(R.id.skill1);
TextView skill1amtTextView = (TextView) view.findViewById(R.id.skill1_amt);
TextView skill2TextView = (TextView) view.findViewById(R.id.skill2);
TextView skill2amtTextView = (TextView) view.findViewById(R.id.skill2_amt);
String decorationNameText = decoration.getName();
String skill1Text = decoration.getSkill1Name();
String skill1amtText = "" + decoration.getSkill1Point();
String skill2Text = decoration.getSkill2Name();
String skill2amtText = "";
if (decoration.getSkill2Point() != 0) {
skill2amtText = skill2amtText + decoration.getSkill2Point();
}
Drawable i = null;
String cellImage = "icons_items/" + decoration.getFileLocation();
try {
i = Drawable.createFromStream(
context.getAssets().open(cellImage), null);
} catch (IOException e) {
e.printStackTrace();
}
itemImageView.setImageDrawable(i);
decorationNameTextView.setText(decorationNameText);
skill1TextView.setText(skill1Text);
skill1amtTextView.setText(skill1amtText);
skill2TextView.setVisibility(View.GONE);
skill2amtTextView.setVisibility(View.GONE);
if (!skill2amtText.equals("")) {
skill2TextView.setText(skill2Text);
skill2amtTextView.setText(skill2amtText);
skill2TextView.setVisibility(View.VISIBLE);
skill2amtTextView.setVisibility(View.VISIBLE);
}
itemLayout.setTag(decoration.getId());
if (fromAsb) {
boolean fitsInArmor = (decoration.getNumSlots() <= maxSlots);
view.setEnabled(fitsInArmor);
// Set the jewel image to be translucent if disabled
// TODO: If a way to use alpha with style selectors exist, use that instead
itemImageView.setAlpha((fitsInArmor) ? 1.0f : 0.5f);
if (fitsInArmor) {
itemLayout.setOnClickListener(new DecorationClickListener(context, decoration.getId(), true, activity));
}
}
else {
itemLayout.setOnClickListener(new DecorationClickListener(context, decoration.getId()));
}
}
@Override
public void onClick(View v) {
EditText etComment = (EditText) context.findViewById(R.id.etText);
String text = etComment.getText().toString().trim();
if (StringUtil.isEmpty(text)
&& etComment.getHint() != null) {
text = etComment.getHint().toString();
}
if (StringUtil.isEmpty(text)) {
Toast.makeText(v.getContext(), R.string.msg_comment_empty, Toast.LENGTH_LONG).show();
return;
}
int byteLen = StringUtil.getLengthByByte(text);
if (byteLen > Constants.STATUS_TEXT_MAX_LENGTH * 2) {
text = StringUtil.subStringByByte(text, 0, Constants.STATUS_TEXT_MAX_LENGTH * 2);
}
v.setEnabled(false);
context.getEmotionViewController().hideEmotionView();
context.displayOptions(true);
//hide input method
InputMethodManager inputMethodManager = (InputMethodManager)v.getContext().
getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(etComment.getWindowToken(), 0);
UpdateCommentTask commentTask = null;
Comment recomment = context.getRecomment();
if (recomment == null) {
commentTask = new UpdateCommentTask(context, text, context.getStatus().getStatusId(), account);
} else {
//String recommentText = text.substring(text.indexOf(":") + 1); //截断评论前的hint
String recommentText = text;
if (account.getServiceProvider() == ServiceProvider.Sohu) {
recommentText = text;
}
if (StringUtil.isEmpty(recommentText)) {
Toast.makeText(context, R.string.msg_comment_empty, Toast.LENGTH_LONG).show();
v.setEnabled(true);
return;
}
commentTask = new UpdateCommentTask(
v.getContext(), recommentText,
context.getStatus().getStatusId(), recomment.getCommentId(),
account
);
}
commentTask.setShowDialog(true);
commentTask.execute();
if (context.isRetweet()) {
String retweetText = text;
if (context.getRecomment() != null) {
retweetText += " //" + context.getRecomment().getUser().getMentionName() +
":" + context.getRecomment().getText();
}
if (context.getStatus().getRetweetedStatus() != null) {
retweetText += " //" + context.getStatus().getUser().getMentionName() +
":" + context.getStatus().getText();
}
byteLen = StringUtil.getLengthByByte(retweetText);
if (byteLen > Constants.STATUS_TEXT_MAX_LENGTH * 2) {
retweetText = StringUtil.subStringByByte(retweetText, 0, Constants.STATUS_TEXT_MAX_LENGTH * 2);
}
RetweetTask retweetTask = new RetweetTask(
context, context.getStatus().getStatusId(), retweetText, account
);
retweetTask.setShowDialog(false);
retweetTask.execute();
}
if (context.isCommentToOrigin()) {
String ctoText = text + " #" + context.getString(R.string.app_name) + "#";
Status retweetedStatus = context.getStatus().getRetweetedStatus();
UpdateCommentTask commenToOriginTask = new UpdateCommentTask(
context, ctoText, retweetedStatus.getStatusId(), account
);
commenToOriginTask.setShowDialog(false);
commenToOriginTask.execute();
}
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.item_change_wallpaper, null);
viewHolder = new ViewHolder();
viewHolder.wallpaperImageView = (ImageView)convertView.findViewById(R.id.wallpaper_imageview);
viewHolder.wallpaperView = (View)convertView.findViewById(R.id.wallpaper_view);
convertView.setTag(viewHolder);
}else
viewHolder = (ViewHolder) convertView.getTag();
/*####################�� ����ֹ�������#########################*/
//����취����ѹ��
//ѹ�������ڽ�ʡBITMAP�ڴ�ռ�--���BUG�Ĺؼ�����
/*BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 4; //�����ֵѹ���ı�����2��������������ֵԽС��ѹ����ԽС��ͼƬԽ����
//����ԭͼ����֮���bitmap����
currentBitmap = BitmapFactory.decodeResource(context.getResources(), picIds[position], opts);*/
if(position == 8){
convertView.setEnabled(false);
}
currentBitmap = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeResource(context.getResources(), picIds[position]), 130, 180);
viewHolder.wallpaperImageView.setImageBitmap(currentBitmap);
if(position == selectPosition){
viewHolder.wallpaperView.setBackgroundColor(context.getResources().getColor(R.color.trans_light_green));
}else{
viewHolder.wallpaperView.setBackgroundColor(Color.TRANSPARENT);
}
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setSelectedPosition(position);
notifyDataSetChanged();
}
});
return convertView;
}
public static void setEnable(boolean enable, View view){
if (view != null){
view.setEnabled(enable);
}
}