gpt4 book ai didi

java - Android SlidingUpPanelLayout 上滑事件

转载 作者:太空宇宙 更新时间:2023-11-03 12:18:26 26 4
gpt4 key购买 nike

我正在使用 https://github.com/umano/AndroidSlidingUpPanel .它工作得很好,但我试图找出一些方法来监听向上/向下滑动事件。我在 README 中没有看到任何与此相关的内容。

文件.xml:

<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:fadeColor="@android:color/transparent"
sothree:panelHeight="30dp"
sothree:shadowHeight="4dp">

<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >

<!-- always visible content -->

</RelativeLayout>


<RelativeLayout android:id="@+id/slider"
android:layout_width="match_parent"
android:layout_height="250dp" >

<!-- slide-able stuff -->

<ImageView
android:id="@+id/sliderImage"
android:layout_width="match_parent"
android:layout_height="20dp"
android:src="@drawable/slide_up"
android:gravity="center|top" />

<ListView
android:id="@+id/table"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/sliderImage" >

</ListView>

</RelativeLayout>

</com.sothree.slidinguppanel.SlidingUpPanelLayout>

一些Java.java:

SlidingUpPanelLayout slider = (SlidingUpPanelLayout)findViewById(R.id.sliding_layout);
ImageView sliderImage = (ImageView)findViewById(R.id.sliderImage);

/* slider.setOnSomethingListenerIdk(new SomeSortOfOnSomethingListener(){
@Override
public boolean onSomething(View view, SomeEvent someEvent) {
if (view.isUpOrSomething) sliderImage.setImageResource(R.drawable.slide_down);
else sliderImage.setImageResource(R.drawable.slide_up);
}
});*/

所以基本上我有一个箭头图像,我想在底部面板向上或向下滑动时更改它。我不知道该怎么做。

最佳答案

如果我没有正确理解你的问题,我想你可能想看看这个

 /**
* Listener for monitoring events about sliding panes.
*/
public interface PanelSlideListener {
/**
* Called when a sliding pane's position changes.
* @param panel The child view that was moved
* @param slideOffset The new offset of this sliding pane within its range, from 0-1
*/
public void onPanelSlide(View panel, float slideOffset);
/**
* Called when a sliding panel becomes slid completely collapsed.
* @param panel The child view that was slid to an collapsed position
*/
public void onPanelCollapsed(View panel);

/**
* Called when a sliding panel becomes slid completely expanded.
* @param panel The child view that was slid to a expanded position
*/
public void onPanelExpanded(View panel);

/**
* Called when a sliding panel becomes anchored.
* @param panel The child view that was slid to a anchored position
*/
public void onPanelAnchored(View panel);

/**
* Called when a sliding panel becomes completely hidden.
* @param panel The child view that was slid to a hidden position
*/
public void onPanelHidden(View panel);
}`

....

/**
* Sets the panel slide listener
* @param listener
*/
public void setPanelSlideListener(PanelSlideListener listener) {
mPanelSlideListener = listener;
}

所以基本上这就是您的操作方式。

slide.setPanelSlideListener(new PanelSlideListener(){
// Override here
});

here 有一个演示

希望对你有帮助:)

关于java - Android SlidingUpPanelLayout 上滑事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25329457/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com