下面列出了android.widget.ImageView#setEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void disableButtons() {
ImageView statusButton = findViewById(R.id.status_button);
ImageView mapButton = findViewById(R.id.map_button);
ImageView inventoryButton = findViewById(R.id.inventory_button);
ImageView runButton = findViewById(R.id.run_button);
ImageView heistButton = findViewById(R.id.heist_button);
ImageView quitButton = findViewById(R.id.quit_button);
statusButton.setAlpha(0.5f);
statusButton.setEnabled(false);
mapButton.setAlpha(0.5f);
mapButton.setEnabled(false);
inventoryButton.setAlpha(0.5f);
inventoryButton.setEnabled(false);
runButton.setAlpha(0.5f);
runButton.setEnabled(false);
heistButton.setAlpha(0.5f);
heistButton.setEnabled(false);
quitButton.setAlpha(0.5f);
quitButton.setEnabled(false);
}
@Override
protected void onBindView(View view)
{
super.onBindView(view);
ImageView actionButton = (ImageView) view.findViewById(R.id.actionButton0);
if (actionButton != null)
{
boolean enabled = isEnabled();
actionButton.setEnabled(enabled);
if (Build.VERSION.SDK_INT >= 11) {
actionButton.setAlpha(enabled ? 1f : 0f);
}
actionButton.setOnClickListener(onActionClicked);
}
}
private void addIndicatorImageViews(int size) {
llIndexContainer.removeAllViews();
for (int i = 0; i < size; i++) {
ImageView iv = new ImageView(mContext);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(DensityUtil.dip2px(mContext, 5), DensityUtil.dip2px(mContext, 5));
if (i != 0) {
lp.leftMargin = DensityUtil.dip2px(mContext, 7);
}
iv.setLayoutParams(lp);
iv.setBackgroundResource(R.drawable.xml_round_orange_grey_sel);
iv.setEnabled(false);
if (i == 0) {
iv.setEnabled(true);
}
llIndexContainer.addView(iv);
}
}
private void prepareDefaultView(int timeOut) {
for (int i = 0; i < mDotsTouched.size(); i++) {
ImageView iv = mDotsTouched.get(i);
iv.setEnabled(true);
}
if (mNeedSetDefItems && timeOut == 0){
setDefaultView();
} else {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (mNeedSetDefItems){
setDefaultView();
}
}
}, timeOut);
}
mDotsTouched.clear();
}
private void addIndicatorImageViews(int size, int resid) {
llIndexContainer.removeAllViews();
for (int i = 0; i < size; i++) {
ImageView iv = new ImageView(getContext());
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ScreenUtil.dp2px(getContext(), 5), ScreenUtil.dp2px(getContext(), 5));
if (i != 0) {
lp.leftMargin = ScreenUtil.dp2px(getContext(), 7);
}
iv.setLayoutParams(lp);
if (resid != 0)
iv.setBackgroundResource(resid);
else
//设置导航点的背景图片
iv.setBackgroundResource(R.drawable.abc_background_indicator);
iv.setEnabled(false);
if (i == 0) {
iv.setEnabled(true);
}
llIndexContainer.addView(iv);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
try {
if (imagesAdapter != null) {
View view = galleryImagesGridView.getChildAt(imagesAdapter.getCount() - 1);
if (view != null) {
ImageView imageView = view.findViewById(R.id.galleryImageView);
if (imageView != null) {
imageView.setEnabled(true);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (resultCode == Activity.RESULT_OK) {
final Uri selectedFileUri = (intent == null ? null : intent.getData());
Utils.printLog(MobiComAttachmentSelectorActivity.this, TAG, "selectedFileUri :: " + selectedFileUri);
if (selectedFileUri != null) {
if (getApplicationContext() instanceof AttachmentFilteringListener) {
AttachmentFilteringListener filteringListener = (AttachmentFilteringListener) getApplicationContext();
filteringListener.onAttachmentSelected(this, selectedFileUri, new AlCallback() {
@Override
public void onSuccess(Object response) {
processUri(selectedFileUri);
}
@Override
public void onError(Object error) {
Utils.printLog(getApplicationContext(), TAG, "Error in file : " + GsonUtils.getJsonFromObject(error, Object.class));
}
});
} else {
processUri(selectedFileUri);
}
}
}
super.onActivityResult(requestCode, resultCode, intent);
}
private void init(Context context) {
this.context = context;
View rootView = LayoutInflater.from(context).inflate(R.layout.web_browser, null);
this.addView(rootView);
layout_loading = (LinearLayout) rootView.findViewById(R.id.layout_loading);
layout_loading.setVisibility(View.GONE);
iv_refresh = (ImageView) rootView.findViewById(R.id.iv_refresh);
iv_refresh.setOnClickListener(myClickListener);
iv_stop = (ImageView) rootView.findViewById(R.id.iv_stop);
iv_stop.setOnClickListener(myClickListener);
iv_goback = (ImageView) rootView.findViewById(R.id.iv_goback);
iv_goback.setOnClickListener(myClickListener);
iv_more = (ImageView) rootView.findViewById(R.id.iv_more);
iv_more.setOnClickListener(myClickListener);
iv_goback.setEnabled(false);
iv_goforward = (ImageView) rootView.findViewById(R.id.iv_goforward);
iv_goforward.setOnClickListener(myClickListener);
iv_goforward.setEnabled(false);
webView = (WebView) rootView.findViewById(R.id.webView);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setSaveFormData(false);
webView.getSettings().setSavePassword(false);
webView.getSettings().setPluginState(PluginState.ON);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBlockNetworkLoads(false);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setRenderPriority(RenderPriority.HIGH);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.setWebChromeClient(myWebChromeClient);
webView.setWebViewClient(myWebViewClient);
webView.setOnTouchListener(myTouchListener);
webView.setDownloadListener(myDownLoadListener);
}
private void initDots(EmoticionMap eMap,int index) {
if (eMap == null)
return;
bottomDot.removeAllViews();
int itemCountPerPage = eMap.showAll == 0 ? 8 : 21;
int viewPagerPageSize = (int) Math.ceil(((double) eMap.count)
/ ((double) itemCountPerPage));
if (viewPagerPageSize > 0) {
if (viewPagerPageSize == 1) {
bottomDot.setVisibility(View.GONE);
} else {
bottomDot.setVisibility(View.VISIBLE);
imageViews = new ImageView[viewPagerPageSize];
int dotFileHeight = Utils.dipToPixels(context, 5);
int dotFileWidth = Utils.dipToPixels(context, 5);
int dotMargin = Utils.dipToPixels(context, 4);
for (int i = 0; i < viewPagerPageSize; i++) {
ImageView image = new ImageView(context);
image.setTag(i);
LayoutParams params = new LayoutParams(dotFileWidth, dotFileHeight);
params.setMargins(dotMargin, dotMargin, dotMargin, dotMargin);
image.setBackgroundDrawable(new DotFile(context).setStateDrawable());
image.setEnabled(false);
bottomDot.addView(image, params);
imageViews[i] = image;
}
imageViews[index].setEnabled(true);
}
}
}
public void initIndicator(int index){
ll_inicatore.removeAllViews();
int viewPagerPageSize = mChatOperationsAdapter.getCount();
if (viewPagerPageSize > 0) {
if (viewPagerPageSize == 1) {
ll_inicatore.setVisibility(View.GONE);
} else {
ll_inicatore.setVisibility(View.VISIBLE);
imageViews = new ImageView[viewPagerPageSize];
int dotFileHeight = Utils.dipToPixels(mContext, 5);
int dotFileWidth = Utils.dipToPixels(mContext, 5);
int dotMargin = Utils.dipToPixels(mContext, 4);
for (int i = 0; i < viewPagerPageSize; i++) {
ImageView image = new ImageView(mContext);
image.setTag(i);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(dotFileWidth, dotFileHeight);
params.setMargins(dotMargin, dotMargin, dotMargin, dotMargin);
image.setBackgroundDrawable(new DotFile(mContext).setStateDrawable());
image.setEnabled(false);
ll_inicatore.addView(image, params);
imageViews[i] = image;
}
imageViews[index].setEnabled(true);
}
}
}
private void setItemIsActive(int position){
ImageView iv = mAllDots.get(position);
iv.setEnabled(false);
if (!isSecretModeEnable()){
makeItemBig(iv);
iv.setImageBitmap(mDotBitmapTouched);
}
mDotsTouched.add(iv);
}
@SuppressLint({"ResourceAsColor"})
private void setStatueView(int level, ImageView statue) {
if (level == 1) {
statue.setVisibility(0);
statue.setEnabled(true);
} else if (level == 2) {
statue.setVisibility(0);
statue.setEnabled(false);
} else {
statue.setVisibility(8);
}
}
private void initViews() {
//提醒设置
ivStart = (ImageView)findViewById(R.id.from);
ivStart.setOnClickListener(this);
ivEnd = (ImageView)findViewById(R.id.to);
ivEnd.setOnClickListener(this);
btnPreReminderTime = (Button)findViewById(R.id.time);
btnPreReminderTime.setOnClickListener(this);
ivRing = (ImageView)findViewById(R.id.ring);
ivRing.setOnClickListener(this);
ivVibrate = (ImageView)findViewById(R.id.vibrate);
ivVibrate.setOnClickListener(this);
tvMIUIRepair = (TextView)findViewById(R.id.repair);
tvMIUIRepair.setOnClickListener(this);
Button btnReminderDemo = (Button)findViewById(R.id.demo);
btnReminderDemo.setOnClickListener(this);
btnPreReminderTime.setText(setSP.getPreReminderTimeString());
ivVibrate.setImageResource(setSP.isVibrate()==true ? R.drawable.chat_on:R.drawable.chat_off);
ivRing.setImageResource(setSP.isRing()==true ? R.drawable.chat_on:R.drawable.chat_off);
ivStart.setImageResource(setSP.isStartReminder()==true ? R.drawable.chat_on:R.drawable.chat_off);
ivEnd.setImageResource(setSP.isEndReminder()==true ? R.drawable.chat_on:R.drawable.chat_off);
if (!setSP.isReminderSet()){
btnPreReminderTime.setEnabled(false);
ivRing.setEnabled(false);
ivVibrate.setEnabled(false);
tvMIUIRepair.setEnabled(false);
}else{
btnPreReminderTime.setEnabled(true);
ivRing.setEnabled(true);
ivVibrate.setEnabled(true);
tvMIUIRepair.setEnabled(true);
}
}
public void setDots(int tabpos) {
dotContainer.removeAllViews();
LayoutParams lpp = new LayoutParams(LWC, LWC);
lpp.setMargins(size8 / 2, 0, size8 / 2, 0);
lpp.gravity = Gravity.CENTER_VERTICAL;
for (int i = 0; i < getPageSize(tabpos); i++) {
ImageView dotImageView = new ImageView(context);
dotImageView.setImageResource(dotImageResourseId);
dotImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
dotImageView.setEnabled(false);
dotContainer.addView(dotImageView, lpp);
}
}
private void setInvisible() {
// Log.d("COLLAGE", "Setting something invisible...");
if (imageViewReference != null) {
final ImageView imageView = imageViewReference.get();
BitmapFetcherTask bitmapDownloaderTask = getBitmapDownloaderTask(imageView);
if (this == bitmapDownloaderTask) {
imageView.setVisibility(View.GONE);
imageView.setClickable(false);
imageView.setEnabled(false);
}
}
}
private void setUpFriendMenu() {
ImageView athleteButton = findViewById(R.id.status_menu_friends_athlete_button);
GameTextView athleteTitle = findViewById(R.id.status_menu_friends_athlete_title);
GameTextView athleteSubTitle = findViewById(R.id.status_menu_friends_athlete_subtitle);
ImageView classmateButton = findViewById(R.id.status_menu_friends_classmate_button);
GameTextView classmateTitle = findViewById(R.id.status_menu_friends_classmate_title);
GameTextView classmateSubTitle = findViewById(R.id.status_menu_friends_classmate_subtitle);
ImageView nerdButton = findViewById(R.id.status_menu_friends_nerd_button);
GameTextView nerdTitle = findViewById(R.id.status_menu_friends_nerd_title);
GameTextView nerdSubTitle = findViewById(R.id.status_menu_friends_nerd_subtitle);
ImageView delinquentButton = findViewById(R.id.status_menu_friends_delinquent_button);
GameTextView delinquentTitle = findViewById(R.id.status_menu_friends_delinquent_title);
GameTextView delinquentSubTitle = findViewById(R.id.status_menu_friends_delinquent_subtitle);
ImageView tuteeButton = findViewById(R.id.status_menu_friends_tutee_button);
GameTextView tuteeTitle = findViewById(R.id.status_menu_friends_tutee_title);
GameTextView tuteeSubTitle = findViewById(R.id.status_menu_friends_tutee_subtitle);
if (GAME.getFriendScore(ATHLETE_INDEX) == 0) {
athleteButton.setAlpha(0.5f);
athleteButton.setEnabled(false);
athleteTitle.setVisibility(View.GONE);
athleteSubTitle.setVisibility(View.GONE);
} else {
athleteButton.setAlpha(1f);
athleteButton.setEnabled(true);
athleteTitle.setVisibility(View.VISIBLE);
athleteSubTitle.setVisibility(View.VISIBLE);
}
if (GAME.getFriendScore(CLASSMATE_INDEX) == 0) {
classmateButton.setAlpha(0.5f);
classmateButton.setEnabled(false);
classmateTitle.setVisibility(View.GONE);
classmateSubTitle.setVisibility(View.GONE);
} else {
classmateButton.setAlpha(1f);
classmateButton.setEnabled(true);
classmateTitle.setVisibility(View.VISIBLE);
classmateSubTitle.setVisibility(View.VISIBLE);
}
if (GAME.getFriendScore(NERD_INDEX) == 0) {
nerdButton.setAlpha(0.5f);
nerdButton.setEnabled(false);
nerdTitle.setVisibility(View.GONE);
nerdSubTitle.setVisibility(View.GONE);
} else {
nerdButton.setAlpha(1f);
nerdButton.setEnabled(true);
nerdTitle.setVisibility(View.VISIBLE);
nerdSubTitle.setVisibility(View.VISIBLE);
}
if (GAME.getFriendScore(DELINQUENT_INDEX) == 0) {
delinquentButton.setAlpha(0.5f);
delinquentButton.setEnabled(false);
delinquentTitle.setVisibility(View.GONE);
delinquentSubTitle.setVisibility(View.GONE);
} else {
delinquentButton.setAlpha(1f);
delinquentButton.setEnabled(true);
delinquentTitle.setVisibility(View.VISIBLE);
delinquentSubTitle.setVisibility(View.VISIBLE);
}
if (GAME.getFriendScore(TUTEE_INDEX) == 0) {
tuteeButton.setAlpha(0.5f);
tuteeButton.setEnabled(false);
tuteeTitle.setVisibility(View.GONE);
tuteeSubTitle.setVisibility(View.GONE);
} else {
tuteeButton.setAlpha(1f);
tuteeButton.setEnabled(true);
tuteeTitle.setVisibility(View.VISIBLE);
tuteeSubTitle.setVisibility(View.VISIBLE);
}
}
public void disableLessonCButtons() {
MiniGame miniGame = GAME.getMiniGame();
if (miniGame != null) {
if (miniGame instanceof LessonC) {
((LessonC) miniGame).setButtons();
}
}
ImageView lessonCRunButton = findViewById(R.id.lesson_c_run_button);
ImageView lessonCWaitButton = findViewById(R.id.lesson_c_wait_button);
ImageView lessonCDrinkButton = findViewById(R.id.lesson_c_drink_button);
ImageView lessonCBookButton = findViewById(R.id.lesson_c_book_button);
ImageView lessonCMapButton = findViewById(R.id.lesson_c_map_button);
ImageView lessonCHelpButton = findViewById(R.id.lesson_c_help_button);
ImageView lessonCInventoryButton = findViewById(R.id.lesson_c_inventory_button);
ImageView lessonCDrinkIcon = findViewById(R.id.lesson_c_drink_icon);
GameTextView lessonCDrinkText = findViewById(R.id.lesson_c_drink_quantity_text);
GameTextView lessonCRunText = findViewById(R.id.lesson_c_run_text);
GameTextView lessonCWaitText = findViewById(R.id.lesson_c_wait_text);
ImageView lessonCBookIcon = findViewById(R.id.lesson_c_book_icon);
GameTextView lessonCBookText = findViewById(R.id.lesson_c_book_quantity_text);
GameTextView lessonCMapText = findViewById(R.id.lesson_c_map_text);
lessonCRunButton.setAlpha(0.5f);
lessonCRunButton.setEnabled(false);
lessonCWaitButton.setAlpha(0.5f);
lessonCWaitButton.setEnabled(false);
lessonCDrinkButton.setAlpha(0.5f);
lessonCDrinkButton.setEnabled(false);
lessonCBookButton.setAlpha(0.5f);
lessonCBookButton.setEnabled(false);
lessonCMapButton.setAlpha(0.5f);
lessonCMapButton.setEnabled(false);
lessonCHelpButton.setAlpha(0.5f);
lessonCHelpButton.setEnabled(false);
lessonCInventoryButton.setAlpha(0.5f);
lessonCInventoryButton.setEnabled(false);
lessonCDrinkIcon.setAlpha(0.5f);
lessonCDrinkText.setAlpha(0.5f);
lessonCRunText.setAlpha(0.5f);
lessonCWaitText.setAlpha(0.5f);
lessonCBookIcon.setAlpha(0.5f);
lessonCBookText.setAlpha(0.5f);
lessonCMapText.setAlpha(0.5f);
}
public void enableLessonCButtons() {
ImageView lessonCRunButton = findViewById(R.id.lesson_c_run_button);
ImageView lessonCWaitButton = findViewById(R.id.lesson_c_wait_button);
ImageView lessonCDrinkButton = findViewById(R.id.lesson_c_drink_button);
ImageView lessonCBookButton = findViewById(R.id.lesson_c_book_button);
ImageView lessonCMapButton = findViewById(R.id.lesson_c_map_button);
ImageView lessonCHelpButton = findViewById(R.id.lesson_c_help_button);
ImageView lessonCInventoryButton = findViewById(R.id.lesson_c_inventory_button);
ImageView lessonCDrinkIcon = findViewById(R.id.lesson_c_drink_icon);
GameTextView lessonCDrinkText = findViewById(R.id.lesson_c_drink_quantity_text);
GameTextView lessonCRunText = findViewById(R.id.lesson_c_run_text);
GameTextView lessonCWaitText = findViewById(R.id.lesson_c_wait_text);
ImageView lessonCBookIcon = findViewById(R.id.lesson_c_book_icon);
GameTextView lessonCBookText = findViewById(R.id.lesson_c_book_quantity_text);
GameTextView lessonCMapText = findViewById(R.id.lesson_c_map_text);
lessonCRunButton.setAlpha(1f);
lessonCRunButton.setEnabled(true);
lessonCWaitButton.setAlpha(1f);
lessonCWaitButton.setEnabled(true);
lessonCDrinkButton.setAlpha(1f);
lessonCDrinkButton.setEnabled(true);
lessonCBookButton.setAlpha(1f);
lessonCBookButton.setEnabled(true);
lessonCMapButton.setAlpha(1f);
lessonCMapButton.setEnabled(true);
lessonCHelpButton.setAlpha(1f);
lessonCHelpButton.setEnabled(true);
lessonCInventoryButton.setAlpha(1f);
lessonCInventoryButton.setEnabled(true);
lessonCDrinkIcon.setAlpha(1f);
lessonCDrinkText.setAlpha(1f);
lessonCRunText.setAlpha(1f);
lessonCWaitText.setAlpha(1);
lessonCBookIcon.setAlpha(1f);
lessonCBookText.setAlpha(1f);
lessonCMapText.setAlpha(1f);
MiniGame miniGame = GAME.getMiniGame();
if (miniGame != null) {
if (miniGame instanceof LessonC) {
((LessonC) miniGame).setButtons();
}
}
}
public void disableSkipButton() {
ImageView skipButton = findViewById(R.id.skip_button);
skipButton.setAlpha(0.5f);
skipButton.setEnabled(false);
}
public void enableSkipButton() {
ImageView skipButton = findViewById(R.id.skip_button);
skipButton.setAlpha(1f);
skipButton.setEnabled(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mInflater = inflater;
View view = inflater.inflate(R.layout.history, container, false);
noCallHistory = (TextView) view.findViewById(R.id.no_call_history);
noMissedCallHistory = (TextView) view.findViewById(R.id.no_missed_call_history);
historyList = (ListView) view.findViewById(R.id.history_list);
historyList.setOnItemClickListener(this);
delete = (ImageView) view.findViewById(R.id.delete);
delete.setOnClickListener(this);
editList = (LinearLayout) view.findViewById(R.id.edit_list);
topBar = (LinearLayout) view.findViewById(R.id.top_bar);
cancel = (ImageView) view.findViewById(R.id.cancel);
cancel.setOnClickListener(this);
allCalls = (ImageView) view.findViewById(R.id.all_calls);
allCalls.setOnClickListener(this);
allCallsSelected = view.findViewById(R.id.all_calls_select);
missedCalls = (ImageView) view.findViewById(R.id.missed_calls);
missedCalls.setOnClickListener(this);
missedCallsSelected = view.findViewById(R.id.missed_calls_select);
selectAll = (ImageView) view.findViewById(R.id.select_all);
selectAll.setOnClickListener(this);
deselectAll = (ImageView) view.findViewById(R.id.deselect_all);
deselectAll.setOnClickListener(this);
allCalls.setEnabled(false);
onlyDisplayMissedCalls = false;
edit = (ImageView) view.findViewById(R.id.edit);
edit.setOnClickListener(this);
return view;
}