我的ScrollViewExt有点问题。当我在视图中滚动时,不会显示任何日志。我读过类似的问题,但我想知道片段的使用是否会改变代码?
在我的日志中我只是:
ScrollViewExt:setOnScrollViewListener
谢谢你的答案。
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);
}
}
我的布局:
<?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>
答案 0 :(得分:0)
我设法得到了一个结果,但我完全改变了SwipeRefreshLayout的布局。
我希望实现的是这个想法,但他唯一真的想念我,如果那不可能那就是可耻的:-),改变转动的箭头,我想要交叉。我设法隐藏了箭头而不是十字架。
http://i.stack.imgur.com/nPgrQ.png
或在这里: http://openclassrooms.com/forum/sujet/android-scrollview-detecter-le-top?page=1#message-88666797