Search code examples
javaandroidandroid-layoutandroid-imageviewandroid-view

Android apps how to fire long press event in video view


I have survey about this subject in a day. What I mean is how to show toast when tapping the Videoview for a while.

Below is what I've found,

Android: Why can't I give an onClickListener to a VideoView?

detect double tap (Double click) or long click in a videoview

But these really can't solve my problem.I really don't know what has happend? And is there any function can fire up long pressing event in the video view?

here's my code

these two event really can't work.

    mVideoView.setOnLongClickListener(new OnLongClickListener() {

        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                final int arg2, long arg3) {
            Log.e("devon","onitemlongclick");
            return true;
        }

        @Override
        public boolean onLongClick(View v) {
            Log.e("devon","onLongClick");
            return true;
        }

    });

need help !!!thanks!


Solution

    • add OnLongClickListener in your setupViewComponent call
    • try using onTouch
    • try attaching the OnLongClickListener to the videoview's surface
    • try wrapping the videoview with a transparent imageview/something that grabs focus, and use that as your 'touching pad'
    • post logcat.