Android标题栏TitleBar全攻略
2010-08-20 01:57:00 来源:WEB开发网}
int x = (int) event.getX();
int titleRight = mTitleBg.getRight();
if (mTitleBg.isPressed() && x > titleRight + slop) {
mTitleBg.setPressed(false);
mHandler.removeMessages(LONG_PRESS);
} else if (mRtButton.isPressed() && x < titleRight - slop) {
mRtButton.setPressed(false);
}
break;
case MotionEvent.ACTION_CANCEL:
mRtButton.setPressed(false);
mTitleBg.setPressed(false);
mHandler.removeMessages(LONG_PRESS);
break;
case MotionEvent.ACTION_UP:
if (mRtButton.isPressed()) {
if (mInLoad) {
mBrowserActivity.stopLoading();
} else {
mBrowserActivity.bookmarksOrHistoryPicker(false);
}
mRtButton.setPressed(false);
} else if (mTitleBg.isPressed()) {
mHandler.removeMessages(LONG_PRESS);
mBrowserActivity.onSearchRequested();
mTitleBg.setPressed(false);
}
break;
default:
break;
}
return true;
}
boolean isInLoad() {
return mInLoad;
}
void setFavicon(Bitmap icon) {
Drawable[] array = new Drawable[3];
array[0] = new PaintDrawable(Color.BLACK);
PaintDrawable p = new PaintDrawable(Color.WHITE);
array[1] = p;
if (icon == null) {
array[2] = mGenericFavicon;
} else {
array[2] = new BitmapDrawable(icon);
}
LayerDrawable d = new LayerDrawable(array);
d.setLayerInset(1, 1, 1, 1, 1);
d.setLayerInset(2, 2, 2, 2, 2);
mFavicon.setImageDrawable(d);
}
void setLock(Drawable d) {
if (null == d) {
mLockIcon.setVisibility(View.GONE);
更多精彩
赞助商链接