GVKun编程网logo

HTML – 如何确保按下按钮“按下”(html按钮按下状态)

5

在本文中,我们将给您介绍关于HTML–如何确保按下按钮“按下”的详细内容,并且为您解答html按钮按下状态的相关问题,此外,我们还将为您提供关于android–当我按下按钮时其他按钮如何禁用?、and

在本文中,我们将给您介绍关于HTML – 如何确保按下按钮“按下”的详细内容,并且为您解答html按钮按下状态的相关问题,此外,我们还将为您提供关于android – 当我按下按钮时其他按钮如何禁用?、android – 当用户按下按钮直到用户释放该按钮时,如何调用函数重复、Android 点击ImageButton时有“按下”的效果的实现、Android:如何在软键盘上方按下按钮的知识。

本文目录一览:

HTML – 如何确保按下按钮“按下”(html按钮按下状态)

HTML – 如何确保按下按钮“按下”(html按钮按下状态)

我正在使用BootStrap Group Button类,发现在我自己的代码中,如果按下按钮,按钮会在几秒钟内弹回….

如何确保它保持按下状态?

<div>
<div>
    <div>
        <label>Stage of business:</label>
        <br />
        <div>
            <button><span>Start-up</span>
            </button>
            <button><span>Growth Company</span>
            </button>
            <button><span>Mature Company</span>
            </button>
        </div>
    </div>
</div>

谢谢.

更新

我添加了活跃的CSS和
我发现当我单击按钮时整个页面都会刷新,这就是按钮失去活动css类的原因.
如何仅对这3个按钮禁用提交操作?因为我有一个按钮,也是这种形式,它需要触发提交动作.

$('.btn-stage').click(function () {
            $(this).toggleClass("active"); //addCss("active");
        })

更新3

此外,在此按钮组中,只能选择一个按钮,如果选择了其他按钮,则其余按钮应该反弹.

谢谢.

解决方法

向按钮添加活动类应该保持“按下”样式.
$('.btn').click(function(e) {
    e.preventDefault();
    $(this).addClass('active');
})

希望有所帮助.

android – 当我按下按钮时其他按钮如何禁用?

android – 当我按下按钮时其他按钮如何禁用?

我有一些有onclicklistener的imageview.如果我按下一个(不是发布),我可以按其他人或我可以同时点击它们.我不想要这个.每当我按下其中一个时,其他人应该禁用点击.

imageview1.setonClickListener(new View.OnClickListener() {
            public void onClick(View v) {

                getmethod();

            }
        });

我想,我尝试了setClickable(false);但它没有正常工作,如果我点击一个按钮后,它工作.

解决方法

尝试使用onTouchListener而不是onClickListener并调用setEnabled(false);在那里的其他意见.这是一个相当基本的例子:

OnTouchListener onTouchListener = new OnTouchListener() {
    @Override
    public boolean onTouch(View view,MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            imageView1.setEnabled(false);
            imageView2.setEnabled(false);
        }
        return true;
    }
};

然后将其应用于图像视图:

imageView1.setonTouchListener(onTouchListener);

这应该工作.但有一件事是,虽然你只能按一个按钮,但是你放手后也无法推动任何东西 – 但是,你可以通过添加一些逻辑来确定是否视图实际上被点击了或者如果用户触摸它,改变了主意并且滑走了.即使用户只是滚动,(event.getAction()== MotionEvent.ACTION_DOWN)检查也是如此.

android – 当用户按下按钮直到用户释放该按钮时,如何调用函数重复

android – 当用户按下按钮直到用户释放该按钮时,如何调用函数重复

在 android中,

如何在用户按下按钮之前重复调用某个功能,直到他/她释放该按钮?

我检查了clickListener和longclicklistener,但看起来他们并不像我想要的那样.

谢谢.

解决方法

您可以使用OnTouchListener:

public class MainActivity extends Activity implements OnTouchListener
{

    private Button button;

    // ...

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        // ...

        button = (Button) findViewById(R.id.button_id);
        button.setonTouchListener(this);

        // ...
    }

    // ...

    @Override
    public boolean onTouch(View v,MotionEvent event)
    {
        /* get a reference to the button that is being touched */
        Button b = (Button) v;

        /* get the action of the touch event */
        int action = event.getAction();

        if(action == MotionEvent.ACTION_DOWN)
        {
            /*
                A pressed gesture has started,the motion contains
                the initial starting location.
            */
        }
        else if(action == MotionEvent.ACTION_UP)
        {
            /*
                A pressed gesture has finished,the motion contains
                the final release location as well as any intermediate
                points since the last down or move event.
            */
        }
        else if(action == MotionEvent.ACTION_MOVE)
        {
            /*
                A change has happened during a press gesture (between
                ACTION_DOWN and ACTION_UP). The motion contains the
                most recent point,as well as any intermediate points
                since the last down or move event.
            */
        }
        else if(action == MotionEvent.ACTION_CANCEL)
        {
            /*
                The current gesture has been aborted. You will not
                receive any more points in it. You should treat this
                as an up event,but not perform any action that you
                normally would.
            */
        }
    }
}

Android 点击ImageButton时有“按下”的效果的实现

Android 点击ImageButton时有“按下”的效果的实现

 Android 点击ImageButton时有“按下”的效果的实现

1为ImageButton添加图片后,有边框,看起来像是图片贴在了一个按扭上面,要多丑有多丑。

解决办法:ImageButton背景设为透明:#0000

2.使用Button时为了让用户有“按下”的效果,有两种实现方式:

A.

imageButton.setonTouchListener(new OnTouchListener(){   
            @Override  
            public boolean onTouch(View v,MotionEvent event) {   
                if(event.getAction() == MotionEvent.ACTION_DOWN){   
                    //更改为按下时的背景图片   
                    v.setBackgroundResource(R.drawable.pressed);   
                }else if(event.getAction() == MotionEvent.ACTION_UP){   
                    //改为抬起时的图片   
                    v.setBackgroundResource(R.drawable.released);   
                }   
                return false;   
            }   
        });  

B.

<?xml version="1.0" encoding="UTF-8"?>  
<selector xmlns:android="http://schemas.android.com/apk/res/android">  
  <item android:state_pressed="false" android:drawable="@drawable/button_add" />  
  <item android:state_pressed="true"  android:drawable="@drawable/button_add_pressed" />  
  <item android:state_focused="true"  android:drawable="@drawable/button_add_pressed" />  
  <item android:drawable="@drawable/button_add" />  
</selector>  

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

Android:如何在软键盘上方按下按钮

Android:如何在软键盘上方按下按钮

我有一个“保存”按钮,我想与软键盘一起向上推。因此,当用户单击我的布局中的EditText时,按钮必须保持在键盘上方。现在,该按钮将隐藏在键盘下方。你怎么做到这一点?

提前致谢!

答案1

小编典典

您需要将键盘的输入模式设置为adjustResize。您可以这样做,将以下行添加到清单中您的活动属性中:

    android:windowSoftInputMode="adjustResize"

这是在活动中添加的属性的示例:

<activity      android:name=".activity.MyActivity"     android:windowSoftInputMode="adjustResize"></activity>

关于HTML – 如何确保按下按钮“按下”html按钮按下状态的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于android – 当我按下按钮时其他按钮如何禁用?、android – 当用户按下按钮直到用户释放该按钮时,如何调用函数重复、Android 点击ImageButton时有“按下”的效果的实现、Android:如何在软键盘上方按下按钮的相关信息,请在本站寻找。

本文标签: