【问题标题】:Long Click event firing on the Button Click in Android在 Android 中的 Button Click 上触发 Long Click 事件
【发布时间】:2010-12-18 04:42:39
【问题描述】:

我听说我们可以在Android中通过按住按钮片刻来创建按钮的点击事件。

我想在我的应用程序中使用该功能。

谁能告诉我怎么做?

谢谢, 大卫

【问题讨论】:

    标签: android button click


    【解决方案1】:

    View.OnLongClickListener

    public class MyActivity extends Activity {
       protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
    
         setContentView(R.layout.content_layout_id);
    
         final Button button = (Button) findViewById(R.id.button_id);
         button.setOnLongClickListener(new View.OnLongClickListener() {
             public boolean onLongClick(View v) {
                 // Perform action on click
                 return true;
             }
         });
       }
    }
    

    【讨论】:

      猜你喜欢
      • 2011-04-05
      • 2012-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多