Long Press Button Event Handler
android
Solution
You can't do this via XML. Instead, use:
Button button = (Button) findViewById(R.id.btn_NextLift);
button.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
return true;
}
});
Make sure this code comes after `setContentView()` has been called.
Also, make sure that the `longClickable` property is set to true.
Problem
I have seen several articles such as this one describing how to handle a long press event with a button. I can follow these directions but I am wondering if it is possible to do it the same way I handled a click. The way I handled a click was to define the handler in XML as such: ``` <Button android:id="@+id/btn_NextLift" ... android:onClick="btn_NextLiftClick" /> ``` then in code as such: ``` public void btn_NextLiftClick(View vw_Current) {...} ``` I do see the boolean property longClickable in the xml but I don't see where to define an event handler so...??? TIA JB