Android Open Source - Joetz-Android-V2 My Linear Layout

From Project

Back to project page Joetz-Android-V2.


The source code is released under:

GNU General Public License

If you think the Android project Joetz-Android-V2 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.jens.myapplication.view;
//from   w w  w.  j a  v a2 s. c  om
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.LinearLayout;

 * Can be used to listen to touch events from the dispatchTouchEvent method
public class MyLinearLayout extends LinearLayout {
    private OnDispatchTouchEventListener onDispatchTouchEventListener = null;

    public MyLinearLayout(Context context) {

    public MyLinearLayout(Context context, AttributeSet attrs) {
        super(context, attrs);

    public MyLinearLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

    public boolean dispatchTouchEvent(MotionEvent ev) {
        if(onDispatchTouchEventListener != null){
        return super.dispatchTouchEvent(ev);

    public void setOnDispatchTouchEventListener(OnDispatchTouchEventListener listener){
        this.onDispatchTouchEventListener = listener;

    public interface OnDispatchTouchEventListener{
        public void onDispatchTouchEvent(MotionEvent e);

Java Source Code List