<HorizontalScrollView
        android:id="@+id/horizontalScrollView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp" >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal" >
            <Button
                android:id="@+id/button1"
                android:layout_width="200dp"
                android:layout_height="150dp"
                android:text="Song1" />
            <Button
                android:id="@+id/button2"
                android:layout_width="200dp"
                android:layout_height="150dp"
                android:text="Song2" />
            <Button
                android:id="@+id/button3"
                android:layout_width="200dp"
                android:layout_height="150dp"
                android:text="Song3" />
        </LinearLayout>
    </HorizontalScrollView>
    
1 个评论
你可以在以下类似问题中查看这个答案stackoverflow.com/a/55256185/1843984
android
Devrath
Devrath
发布于 2015-02-24
4 个回答
Waqar Aslam
Waqar Aslam
发布于 2020-12-10
已采纳
0 人赞同

以下是对我有用的方法。

Note: It will only work for Double click, it can't handle single click & double click actions seperately

// Define 2 global class variables
private static long LAST_CLICK_TIME = 0;
private final int mDoubleClickInterval = 400; // Milliseconds
// Then, inside onClick method of Button
long doubleClickCurrentTime = System.currentTimeMillis();
long currentClickTime = System.currentTimeMillis();
if (currentClickTime - LAST_CLICK_TIME <= mDoubleClickInterval)
    Toast.makeText(this, "Double click detected", Toast.LENGTH_SHORT).show();
    LAST_CLICK_TIME = System.currentTimeMillis();
    // !Warning, Single click action problem
    
cyclical
cyclical
发布于 2020-12-10
0 人赞同

这里有一个很好的答案。

安卓系统中的单次点击和双击按钮

然而,我建议使用OnLongPress事件,这也是谷歌推荐的方法。

在此查看该API。

http://developer.android.com/reference/android/view/View.OnLongClickListener.html

Cheers

Javid Sattar
Javid Sattar
发布于 2020-12-10
0 人赞同

I use this solotion :

    var doubleTap = false
    your_button.setOnClickListener {
        if (doubleTap)
            handleClick(it.context)
        doubleTap = true
        Handler(Looper.getMainLooper()).postDelayed({
            doubleTap = false
        }, 1500)

你可以在onBackPress活动中使用这个技巧来退出应用程序的拖动步骤。

Good Luck

Nicholas Anyanwu
Nicholas Anyanwu
发布于 2020-12-10
0 人赞同
private int buttonClick = 0;
private void fabVisibility () {
    fabOpen.setOnClickListener (v -> {
        if (buttonClick == 0){
            buttonClick = 2;
            overridePendingTransition (R.anim.fade_in, R.anim.fade_out);
            scanFab.setVisibility (View.VISIBLE);
            historyFab.setVisibility (View.VISIBLE);
        }else if (buttonClick == 2){
            buttonClick = 0;
            overridePendingTransition (R.anim.fade_in, R.anim.fade_out);
            scanFab.setVisibility (View.GONE);