I am working on xamarin android in visual studio. I have added a scroll view
in my layout
and inside it i have placed my linear layout
and then two plot views
in which there are two charts are initialized. While running the app i am getting the bellow error
'MainActivity' does not implement interface member 'ViewTreeObserver.IOnScrollChangedListener.OnScrollChanged()'
Bellow is my xml
of layout
<?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>
Bellow is my main activity code with including
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
}
}
Bellow is the image where i am getting underlined red mark
Any help would be highly appreciated
Your activity has to implement method OnScrollChanged
, but it does not. It has only OnScrollChange
(missing d
on the end: onScrollChanged)