Xamarin의 C#을 사용하여 Android 앱을 만듭니다. scrollview 확장을 만들었습니다. 여기에Scamview 수신기가 Xamarin for Android에서 작동하지 않습니까?
public class EndlessScroll : ScrollView
{
public EndlessScroll (Context context) : base (context)
{
}
public EndlessScroll(Context context, IAttributeSet attrs) : base(context, attrs)
{
}
public EndlessScroll(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
{
}
public interface OnScrollViewListener
{
void onScrollChanged(EndlessScroll v, int l, int t, int oldl, int oldt);
}
public OnScrollViewListener scrollViewListener;
public void setOnScrollViewListener(OnScrollViewListener scrollViewListener) {
this.scrollViewListener = scrollViewListener;
}
protected void onScrollChanged(int l, int t, int oldl, int oldt)
{
base.OnScrollChanged(l, t, oldl, oldt);
if (scrollViewListener != null) {
scrollViewListener.onScrollChanged(this, l, t, oldl, oldt);
}
}
}
내 코드}
내가 다른 클래스로 구현하려고합니다. 컴파일 오류는 없지만 scrollview가 아래쪽에 도달하면 등록되지 않습니다. 다음은 여기에있는 코드입니다.
public class getFromParse:Activity, EndlessScroll.OnScrollViewListener {
LinearLayout linear;
Button buttonSort;
Typeface font;
protected override void OnCreate (Bundle bundle)
{
Window.RequestFeature(WindowFeatures.NoTitle);
base.OnCreate (bundle);
SetContentView (Resource.Layout.debugLog);
EndlessScroll scroll = FindViewById <EndlessScroll> (Resource.Id.scrollView);
scroll.setOnScrollViewListener (this);
그리고 스크롤 뷰 수신기는 아래쪽에있을 때이를 감지합니다.
public void onScrollChanged(EndlessScroll scrollView, int x, int y, int oldx, int oldy) {
// We take the last son in the scrollview
View view = (View) scrollView.GetChildAt(scrollView.ChildCount - 1);
int diff = (view.Bottom - (scrollView.Height + scrollView.ScrollY));
// if diff is zero, then the bottom has been reached
if (diff == 0) {
Console.WriteLine ("Scroll changed");
}
}
누구든지 나를 도울 수 있고 내가 뭘 잘못하고 있는지 알려주면 큰 도움이 될 것입니다. 나는 모든 것을 올바르게하고있는 것으로 보이지만 나는 뭔가를 놓칠지도 모른다.
해결책을 찾았지만이 컨트롤을 사용해 보셨습니까? https://github.com/XLabs/Xamarin-Forms-Labs/wiki/CarouselView – kyurkchyan