0

我正在使用Visual Studio中的xamarin android。我已在我的layout中添加了一個scroll view,並在其中放置了我的linear layout,然後兩個plot views,其中有兩個圖表被初始化。當運行應用程序我得到波紋錯誤Xamarin android'MainActivity'不實現接口成員

'MainActivity' does not implement interface member 'ViewTreeObserver.IOnScrollChangedListener.OnScrollChanged()' 

貝婁是我的佈局xml

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/MainLayout_ScrollView1" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:id="@+id/linearLayout1"> 
    <OxyPlot.Xamarin.Android.PlotView 
     android:layout_width="match_parent" 
     android:layout_height="254.5dp" 
     android:id="@+id/plotView1" /> 
    <OxyPlot.Xamarin.Android.PlotView 
     android:layout_width="match_parent" 
     android:layout_height="309.5dp" 
     android:id="@+id/plotView2" /> 
</LinearLayout></ScrollView> 

貝婁是包括

using Android.App; 
using Android.Content; 
using Android.Runtime; 
using Android.Views; 
using Android.Widget; 
using Android.OS; 
using OxyPlot.Xamarin.Android; 
using OxyPlot; 
using OxyPlot.Axes; 
using OxyPlot.Series; 
using OxyPlot.Annotations; 
using Java.Util; 
using System.Linq; 
using System.Collections.Generic; 
[Activity(Label = "SampleChart", MainLauncher = true, Icon = "@drawable/icon")] 
public class MainActivity : Activity , ViewTreeObserver.IOnScrollChangedListener 
{ 

    private static Toast _PageToast; 
    protected override void OnCreate(Bundle bundle) 
    { 
     base.OnCreate(bundle); 

     // Set our view from the "main" layout resource 
     SetContentView (Resource.Layout.Main); 

     PlotView view = FindViewById<PlotView>(Resource.Id.plotView1); 
     PlotView view2 = FindViewById<PlotView>(Resource.Id.plotView2); 

     view.Model = CreatePlotModel(); 
     view2.Model = CreatePlotModel2(); 

     ScrollView MainLayout_ScrollView1 = (ScrollView)FindViewById(Resource.Id.MainLayout_ScrollView1); 
     MainLayout_ScrollView1.ViewTreeObserver.AddOnScrollChangedListener(this); 
    } 

public void OnScrollChange() 
    { 
     if(_PageToast !=null) 
     { 
      _PageToast.Cancel(); 
     } 

     ScrollView MainLayout_ScrollView1 = ((ScrollView)FindViewById(Resource.Id.MainLayout_ScrollView1)); 

     double scrollingSpace = MainLayout_ScrollView1.GetChildAt(0).Height - MainLayout_ScrollView1.Height; 

     if(scrollingSpace <= MainLayout_ScrollView1.ScrollY) 
     { 
      _PageToast = Toast.MakeText(this, "You have reached to the bottom", ToastLength.Short); 
      _PageToast.Show(); 
     } 
     else 
     { 
      //Do things here 
     } 
    } 

貝婁的圖像在我的主要活動代碼我越來越underlined red mark

enter image description here

任何幫助將高度讚賞

回答

1

您的活動必須實施方法OnScrollChanged,但事實並非如此。它只有OnScrollChange(結尾缺少d:onScrollChange d

相關問題