Toggle div on click or touch and hide on click/touch outside

前端 未结 3 1220
予麋鹿
予麋鹿 2021-01-24 05:10

I\'m trying to support both mouse and touch events for a div that I want to show and hide. My mouse events work well, but I\'m not sure of how to get this to work on a touch-bas

3条回答
  •  甜味超标
    2021-01-24 05:49

    You can also use setOnClickListener event and override onClick function like this :

    btnclickme = (Button) findViewById(R.id.btn_clickme);
    btnclickme.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                            // do your code here
                }
    });
    

提交回复
热议问题