本文整理汇总了Java中android.support.design.widget.SwipeDismissBehavior.setListener方法的典型用法代码示例。如果您正苦于以下问题:Java SwipeDismissBehavior.setListener方法的具体用法?Java SwipeDismissBehavior.setListener怎么用?Java SwipeDismissBehavior.setListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.design.widget.SwipeDismissBehavior
的用法示例。
在下文中一共展示了SwipeDismissBehavior.setListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
}
});
}
示例2: subscribeActual
import android.support.design.widget.SwipeDismissBehavior; //导入方法依赖的package包/类
@Override protected void subscribeActual(Observer<? super View> observer) {
if (!checkMainThread(observer)) {
return;
}
if (!(view.getLayoutParams() instanceof LayoutParams)) {
throw new IllegalArgumentException("The view is not in a Coordinator Layout.");
}
LayoutParams params = (LayoutParams) view.getLayoutParams();
final SwipeDismissBehavior behavior = (SwipeDismissBehavior) params.getBehavior();
if (behavior == null) {
throw new IllegalStateException("There's no behavior set on this view.");
}
Listener listener = new Listener(behavior, observer);
observer.onSubscribe(listener);
behavior.setListener(listener);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}