I've a little problem on my ScrollViewExt. When I scroll in my view no log is displayed. I read similar problems but I wonder if the use of fragment doesn't change the code a bit ?
In my Log I've just :
ScrollViewExt﹕ setOnScrollViewListener
Thx all for your answers.
ScrollViewExt :
public class ScrollViewExt extends ScrollView {
private OnScrollViewListener scrlViewListener;
public ScrollViewExt(Context context) {
super(context);
}
public ScrollViewExt(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ScrollViewExt(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void setOnScrollViewListener(OnScrollViewListener l) {
Log.d("ScrollViewExt", "setOnScrollViewListener ");
this.scrlViewListener = l;
}
@Override
protected void onScrollChanged(int x, int y, int oldx, int oldy) {
Log.d("ScrollViewExt", "onScrollChanged");
super.onScrollChanged(x, y, oldx, oldy);
if(scrlViewListener != null) {
scrlViewListener.onScrollChanged(this, x, y, oldx, oldy);
}
}
}
FragmentNew.java :
public class FragmentNew extends Fragment implements OnScrollViewListener {
ScrollViewExt scrlvNew;
public FragmentNew() {
}
@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_new, container,
false);
scrlvNew = (ScrollViewExt) view.findViewById(R.id.scrlvFragmentNew);
scrlvNew.setOnScrollViewListener(this);
return view;
}
@Override
public void onScrollChanged(ScrollViewExt v, int x, int y, int oldl, int oldt) {
Log.d("FragmentNew", "onScrollChanged");
Log.d("Fragment", "x : " + x);
Log.d("Fragment", "y : " + y);
Log.d("Fragment", "oldx : " + oldl);
Log.d("Fragment", "oldy : " + oldt);
}
}
My Layout :
<?xml version="1.0" encoding="utf-8"?>
<com.application.view.ScrollViewExt
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrlvFragmentNew"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical"
android:overScrollMode="always"
android:isScrollContainer="true"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="outsideInset"
android:scrollbars="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
android:textColor="@android:color/black"/>
<TextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15dp"
android:textColor="@android:color/black"
android:layout_below="@+id/title"/>
</RelativeLayout>
</com.application.view.ScrollViewExt>