I am extending a Fragment
called Scanlist
. It is laid out properly and looks how I want it. Problem is I am unable to Override onInterceptTouchEvent
on the extended Fragment
. So I thought of extending ViewGroup
, Override onInterceptTouchEvent
and then add my Fragment
to the ViewGroup
. When I add my Fragment
to the ViewGroup
the Fragment
is not showing up inside the ViewGroup
. I know the ViewGroup
is there because I am able to Log
the onInterceptTouchEvent
but the screen is blank.
Here is the Fragment:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mRootview = (ViewGroup) inflater.inflate(R.layout.scanlist, container, false);
mRootview.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
mSharedData = new SharedData(mContext);
costomListViewArr = mSharedData.getvins();
Resources res = getResources();
mList = (ListView)mRootview.findViewById(R.id.list);
mAdapter = new Scanvinadapter(mActivity, costomListViewArr, res);
mList.setAdapter(mAdapter);
mAdapter.setimplements(this);
ViewGroup vg = new Scanlistview(mContext);
vg.addView(mRootview);
return vg;
}
Here is the ViewGroup
public class Scanlistview extends ViewGroup{
@SuppressWarnings("unused")
private final String TAG = this.getClass().getSimpleName();
LayoutInflater mInflater;
public Scanlistview(Context context) {
super(context);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev){
Log.v(TAG, "onInterceptTouchEvent");
return false;
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
}
}
scanlist.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/flScanlist"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/vinlist_bg">
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/vinlist_selector"
android:listSelector="@drawable/vinlist_selector"/>
</FrameLayout>