本文整理汇总了Java中android.view.View.post方法的典型用法代码示例。如果您正苦于以下问题:Java View.post方法的具体用法?Java View.post怎么用?Java View.post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClick
import android.view.View; //导入方法依赖的package包/类
@Override
public void onClick(final View view) {
switch (view.getId()){
case R.id.fab:
addConnection();
break;
case R.id.button_popup:
final int position = mListView.getPositionForView(view);
if (position != ListView.INVALID_POSITION) {
view.post(new Runnable() {
@Override
public void run() {
showPopupMenu(view, position);
}
});
}
break;
}
}
示例2: shake
import android.view.View; //导入方法依赖的package包/类
public static void shake(final View view, final Animator.AnimatorListener listener) {
view.clearAnimation();
view.post(new Runnable() {
@Override
public void run() {
view.setPivotX(view.getWidth()/2);
view.setPivotY(view.getHeight());
ObjectAnimator shakeAnim = ObjectAnimator.ofFloat(view, "rotation", 0f,-15f,0f, 15f, 0f).setDuration(1200);
// shakeAnim.setInterpolator(new AccelerateInterpolator());
if(listener!=null) {
shakeAnim.addListener(listener);
}
shakeAnim.setStartDelay(500);
shakeAnim.start();
}
});
}
示例3: tryPassFirstViewToPrevious
import android.view.View; //导入方法依赖的package包/类
private boolean tryPassFirstViewToPrevious(DocumentColumn current, DocumentColumn previous) {
final View view = current.getViewCount() == 0 ? null : current.getViewAt(0);
if (view != null && previous.canTake(view, view.getLayoutParams(), false)) {
mLog.i("tryPassFirstViewToPrevious:", "passing view", Utils.mark(view),
"from", current.getNumber(), "to", previous.getNumber());
boolean hasFocus = view.hasFocus();
current.release(view);
previous.take(view, view.getLayoutParams());
if (hasFocus) {
view.post(new Runnable() {
@Override
public void run() {
view.requestFocus();
Utils.showKeyboard(view);
}
});
}
return true;
}
return false;
}
示例4: animatePropertyBy
import android.view.View; //导入方法依赖的package包/类
/**
* Utility function, called by animateProperty() and animatePropertyBy(), which handles the
* details of adding a pending animation and posting the request to start the animation.
*
* @param constantName The specifier for the property being animated
* @param startValue The starting value of the property
* @param byValue The amount by which the property will change
*/
private void animatePropertyBy(int constantName, float startValue, float byValue) {
// First, cancel any existing animations on this property
if (mAnimatorMap.size() > 0) {
Animator animatorToCancel = null;
Set<Animator> animatorSet = mAnimatorMap.keySet();
for (Animator runningAnim : animatorSet) {
PropertyBundle bundle = mAnimatorMap.get(runningAnim);
if (bundle.cancel(constantName)) {
// property was canceled - cancel the animation if it's now empty
// Note that it's safe to break out here because every new animation
// on a property will cancel a previous animation on that property, so
// there can only ever be one such animation running.
if (bundle.mPropertyMask == NONE) {
// the animation is no longer changing anything - cancel it
animatorToCancel = runningAnim;
break;
}
}
}
if (animatorToCancel != null) {
animatorToCancel.cancel();
}
}
NameValuesHolder nameValuePair = new NameValuesHolder(constantName, startValue, byValue);
mPendingAnimations.add(nameValuePair);
View v = mView.get();
if (v != null) {
v.removeCallbacks(mAnimationStarter);
v.post(mAnimationStarter);
}
}
示例5: startCloneAnimation
import android.view.View; //导入方法依赖的package包/类
private void startCloneAnimation(View clonedView, View targetView) {
clonedView.post(() -> {
TransitionManager.beginDelayedTransition(
(ViewGroup) binding.getRoot(), selectedViewTransition);
// Fires the transition
clonedView.setLayoutParams(SelectedParamsFactory
.endParams(clonedView, targetView));
});
}
示例6: fixLandscapePeekHeight
import android.view.View; //导入方法依赖的package包/类
private void fixLandscapePeekHeight(final View sheet) {
// On landscape, we shouldn't use the 16:9 keyline alignment
sheet.post(new Runnable() {
@Override
public void run() {
mBehavior.setPeekHeight(sheet.getHeight() / 2);
}
});
}
示例7: setLightStatusBarIcons
import android.view.View; //导入方法依赖的package包/类
public static void setLightStatusBarIcons(final View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
v.post(new Runnable() {
@Override
public void run() {
v.setSystemUiVisibility(0);
}
});
}
}
示例8: updateAdapterScaleAndAlpha
import android.view.View; //导入方法依赖的package包/类
private void updateAdapterScaleAndAlpha(final float alpha, final float scale) {
final List<View> pageViews = mAdapter.getViews();
final int curPos = mViewPager.getCurrentItem();
if(pageViews.size() > 0) {
final View currentPage = pageViews.get(curPos);
updateScaleAndAlpha(((ViewGroup)currentPage).getChildAt(0),1.0F,WX_DEFAULT_MAIN_NEIGHBOR_SCALE);
if(pageViews.size() < 2) {
return;
}
//make sure View's width & height are measured.
currentPage.post(WXThread.secure(new Runnable() {
@Override
public void run() {
//change left and right page's translation
updateNeighbor(currentPage, alpha, scale);
}
}));
// make sure only display view current, left, right.
int left = (curPos == 0) ? pageViews.size()-1 : curPos-1;
int right = (curPos == pageViews.size()-1) ? 0 : curPos+1;
for(int i =0; i<mAdapter.getRealCount(); i++) {
if(i != left && i != curPos && i != right) {
((ViewGroup)pageViews.get(i)).getChildAt(0).setAlpha(0F);
}
}
}
}
示例9: setUpRecyclerView
import android.view.View; //导入方法依赖的package包/类
private void setUpRecyclerView() {
setUpRecyclerViewPadding();
recyclerView.setScrollViewCallbacks(observableScrollViewCallbacks);
final View contentView = getWindow().getDecorView().findViewById(android.R.id.content);
contentView.post(new Runnable() {
@Override
public void run() {
songsBackgroundView.getLayoutParams().height = contentView.getHeight();
observableScrollViewCallbacks.onScrollChanged(-(albumArtViewHeight + titleViewHeight), false, false);
// necessary to fix a bug
recyclerView.scrollBy(0, 1);
recyclerView.scrollBy(0, -1);
// if (getAlbum().getSongCount() > 10) {
// ViewGroup.LayoutParams params = recyclerView.getLayoutParams();
// params.height = contentView.getHeight() * 3;
// recyclerView.setLayoutParams(params);
// recyclerView.requestLayout();
// }else {
// ViewGroup.LayoutParams params = recyclerView.getLayoutParams();
// params.height = (int) (contentView.getHeight());
// recyclerView.setLayoutParams(params);
// recyclerView.requestLayout();
// }
//
// recyclerView.setTranslationY(-(albumArtViewHeight + getResources().getDimensionPixelSize(R.dimen.thirthy_dp)));
}
});
}
示例10: setResetAfter
import android.view.View; //导入方法依赖的package包/类
/**
* 设置需要松开回弹的view
*
* @param view view
* @param isFillAfter true需要,false不需要(用于清除)
*/
public void setResetAfter(final View view, boolean isFillAfter) {
boolean hasKey = fillAfterMap.containsKey(view);
//需要添加
if (isFillAfter) {
if (hasKey) {
return;//已经存在直接返回
} else {
//不存在,进行添加
view.post(new Runnable() {
@Override
public void run() {
if (view == null)
return;
Point point = new Point();
point.x = view.getLeft();
point.y = view.getTop();
fillAfterMap.put(view, point);
}
});
}
} else {
//不添加
if (hasKey) {
//有数据,进行删除
fillAfterMap.remove(view);
} else {
return;
}
}
}
示例11: gotoPage
import android.view.View; //导入方法依赖的package包/类
private void gotoPage(View v, final int pageNum)
{
spinner = createAndShowWaitSpinner(this);
mWaitingForIdle = true;
v.post(new Runnable() {
@Override
public void run() {
mDocView.setCurrentPage(pageNum);
}
});
}
示例12: setupDialogToSustainAfterRotation
import android.view.View; //导入方法依赖的package包/类
private void setupDialogToSustainAfterRotation(View viewToPostAfter) {
// REMEMBER to dismiss dialog in onPause method
// Make sure that all views are drawn
viewToPostAfter.post(new Runnable() {
@Override
public void run() {
// then check if dialog was previously opened
if (((CustomApplication) getApplication()).wasDialogOpened()) {
buildAndShowDialog();
}
}
});
}
示例13: resetView
import android.view.View; //导入方法依赖的package包/类
private void resetView(final View childView) {
childView.post(new Runnable() {
@Override
public void run() {
if (childView != null) {
childView.setPressed(false);
}
}
});
isPressing = false;
// 置空,防止内存泄漏
mPressedView = null;
}
示例14: runOpMode
import android.view.View; //导入方法依赖的package包/类
@Override
public void runOpMode() {
// hsvValues is an array that will hold the hue, saturation, and value information.
float hsvValues[] = {0F,0F,0F};
// values is a reference to the hsvValues array.
final float values[] = hsvValues;
// get a reference to the RelativeLayout so we can change the background
// color of the Robot Controller app to match the hue detected by the RGB sensor.
final View relativeLayout = ((Activity) hardwareMap.appContext).findViewById(R.id.RelativeLayout);
// bPrevState and bCurrState represent the previous and current state of the button.
boolean bPrevState = false;
boolean bCurrState = false;
// bLedOn represents the state of the LED.
boolean bLedOn = true;
// get a reference to our ColorSensor object.
colorSensor = hardwareMap.colorSensor.get("sensor_color");
// Set the LED in the beginning
colorSensor.enableLed(bLedOn);
// wait for the start button to be pressed.
waitForStart();
// while the op mode is active, loop and read the RGB data.
// Note we use opModeIsActive() as our loop condition because it is an interruptible method.
while (opModeIsActive()) {
// check the status of the x button on either gamepad.
bCurrState = gamepad1.x;
// check for button state transitions.
if ((bCurrState == true) && (bCurrState != bPrevState)) {
// button is transitioning to a pressed state. So Toggle LED
bLedOn = !bLedOn;
colorSensor.enableLed(bLedOn);
}
// update previous state variable.
bPrevState = bCurrState;
// convert the RGB values to HSV values.
Color.RGBToHSV(colorSensor.red() * 8, colorSensor.green() * 8, colorSensor.blue() * 8, hsvValues);
// send the info back to driver station using telemetry function.
telemetry.addData("LED", bLedOn ? "On" : "Off");
telemetry.addData("Clear", colorSensor.alpha());
telemetry.addData("Red ", colorSensor.red());
telemetry.addData("Green", colorSensor.green());
telemetry.addData("Blue ", colorSensor.blue());
telemetry.addData("Hue", hsvValues[0]);
// change the background color to match the color detected by the RGB sensor.
// pass a reference to the hue, saturation, and value array as an argument
// to the HSVToColor method.
relativeLayout.post(new Runnable() {
public void run() {
relativeLayout.setBackgroundColor(Color.HSVToColor(0xff, values));
}
});
telemetry.update();
}
}
示例15: setInitialMeasure
import android.view.View; //导入方法依赖的package包/类
private void setInitialMeasure(final View view) {
view.post(() -> ViewUtil.setViewMeasure(view, ScreenMetrics.getDeviceScreenWidth() * 2 / 3,
ScreenMetrics.getDeviceScreenHeight() / 3));
}