当前位置: 首页>>代码示例>>Java>>正文


Java SwipeDismissBehavior.setSwipeDirection方法代码示例

本文整理汇总了Java中android.support.design.widget.SwipeDismissBehavior.setSwipeDirection方法的典型用法代码示例。如果您正苦于以下问题:Java SwipeDismissBehavior.setSwipeDirection方法的具体用法?Java SwipeDismissBehavior.setSwipeDirection怎么用?Java SwipeDismissBehavior.setSwipeDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.design.widget.SwipeDismissBehavior的用法示例。


在下文中一共展示了SwipeDismissBehavior.setSwipeDirection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupSwipe

import android.support.design.widget.SwipeDismissBehavior; //导入方法依赖的package包/类
private void setupSwipe(ItemTrackedBeaconBinding beaconBinding) {

        final SwipeDismissBehavior<CardView> swipe = new SwipeDismissBehavior();
        swipe.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_ANY);
        swipe.setListener(new SwipeDismissBehavior.OnDismissListener() {
            @Override
            public void onDismiss(View view) {
                Log.d(Constants.TAG, "Swipe +");
            }

            @Override
            public void onDragStateChanged(int state) {
            }
        });

    }
 
开发者ID:vitas,项目名称:beaconloc,代码行数:17,代码来源:TrackedBeaconAdapter.java

示例2: onCreate

import android.support.design.widget.SwipeDismissBehavior; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_swipe_behavior);


	final SwipeDismissBehavior swipe = new SwipeDismissBehavior();
	swipe.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_ANY);
	swipe.setListener(new SwipeDismissBehavior.OnDismissListener() {
		@Override public void onDismiss(View view) {
			Toast.makeText(SwipeBehaviorExampleActivity.this,
				"Card swiped !!", Toast.LENGTH_SHORT).show();
		}

		@Override public void onDragStateChanged(int state) {}
	});

	CardView cardView = (CardView) findViewById(R.id.swype_card);
	LayoutParams coordinatorParams = (LayoutParams) cardView.getLayoutParams();
	coordinatorParams.setBehavior(swipe);
}
 
开发者ID:saulmm,项目名称:CoordinatorExamples,代码行数:22,代码来源:SwipeBehaviorExampleActivity.java

示例3: initBehavior

import android.support.design.widget.SwipeDismissBehavior; //导入方法依赖的package包/类
private void initBehavior() {
    swipeDismissBehavior = new SwipeDismissBehavior();
    swipeDismissBehavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_ANY);
    swipeDismissBehavior.setListener(onDismissListener);
    CoordinatorLayout.LayoutParams coordinatorParams = (CoordinatorLayout.LayoutParams) findViewById(R.id.textview).getLayoutParams();
    coordinatorParams.setBehavior(swipeDismissBehavior);

    swipeDismissBehavior.setDragDismissDistance(0.5F);
    swipeDismissBehavior.setStartAlphaSwipeDistance(0F);
    swipeDismissBehavior.setEndAlphaSwipeDistance(0.5F);
    swipeDismissBehavior.setSensitivity(0);
    swipeDismissBehavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END);
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:14,代码来源:SwipeDismissBehaviorActivity.java

示例4: CardViewHolder

import android.support.design.widget.SwipeDismissBehavior; //导入方法依赖的package包/类
public CardViewHolder(final View itemView) {
    super(itemView);
    userName = (TextView) itemView.findViewById(R.id.user_name);
    userIcon = (ImageView) itemView.findViewById(R.id.user_icon);
    image = (ImageView) itemView.findViewById(R.id.image);

    card = (CardView) itemView.findViewById(R.id.card);
    card.setOnClickListener(this);

    // ドラッグして消えるBehaviorを取り付ける。
    // スワイプする要素は、親ビューがCoordinatorLayoutである必要がある。
    SwipeDismissBehavior behavior = new SwipeDismissBehavior();
    behavior.setStartAlphaSwipeDistance(0.1f);
    behavior.setEndAlphaSwipeDistance(0.6f);
    behavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END);
    behavior.setListener(new SwipeDismissBehavior.OnDismissListener() {
        @Override
        public void onDismiss(View view) {
            if (listener != null) {
                listener.onCardDismiss(CardViewHolder.this);
            }
        }

        @Override
        public void onDragStateChanged(int state) {
            if (listener != null) {
                listener.onDragStateChanged(CardViewHolder.this, state);
            }
        }
    });
    final ViewGroup.LayoutParams cardViewLayoutParams = card.getLayoutParams();
    ((CoordinatorLayout.LayoutParams) cardViewLayoutParams).setBehavior(behavior);
}
 
开发者ID:yokmama,项目名称:honki_android2,代码行数:34,代码来源:CardViewHolder.java


注:本文中的android.support.design.widget.SwipeDismissBehavior.setSwipeDirection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。