Bug 31436 - PagerAdapter GetPageTitle missing virtual keyword
Summary: PagerAdapter GetPageTitle missing virtual keyword
Alias: None
Product: Android
Classification: Xamarin
Component: Bindings ()
Version: 5.2
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Atsushi Eno
Depends on:
Reported: 2015-06-27 14:27 UTC by Richard Davison
Modified: 2016-08-08 07:38 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Richard Davison 2015-06-27 14:27:22 UTC
PagerAdapter source missing virtual keyword.

public string GetPageTitle(int position);
[Register("getPageTitle", "(I)Ljava/lang/CharSequence;", "GetGetPageTitle_IHandler")]

prevents me from overriding the method
Comment 1 Rajneesh Kumar 2015-07-07 06:01:26 UTC
I tried to reproduce this issue but not able to reproduce this. Could you please share steps or a sample application to reproduce this issue, that would be very helpful to reproduce this issue at our end.

Screencast: http://www.screencast.com/t/eDXflH1FXlU1


Environment Info:

=== Xamarin Studio ===

Version 5.9.4 (build 5)
Installation UUID: 08cac54d-8d5b-406e-adf0-707e52f76272
	Microsoft .NET 4.0.30319.18408
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.26

=== Xamarin.Android ===

Version: 5.1.4 (Business Edition)
Android SDK: E:\android-sdk
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39
java version "1.6.0_39"
Java(TM) SE Runtime Environment (build 1.6.0_39-b04)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode)

=== Xamarin Android Player ===

Location: C:\Program Files\Xamarin Android Player\DeviceManager.exe

=== Build Information ===

Release ID: 509040005
Git revision: 8010a90f6e246b32364e3fb46ef2c9d1be9c9a2b
Build date: 2015-06-08 17:16:25-04
Xamarin addins: 7e93e9c3503f28770f23ce1b7eafd829919f18e8

=== Operating System ===

Windows 6.2.9200.0 (64-bit)
Comment 2 imgx64+bz 2015-07-13 05:49:05 UTC
I can reproduce this bug. The bug is in Android Support Library v4 (http://components.xamarin.com/view/xamandroidsupportv4-18/ ), not in the base Android SDK.

The method that should marked virtual is PagerAdapter.getPageTitle (https://developer.android.com/reference/android/support/v4/view/PagerAdapter.html#getPageTitle(int) ) , because it's used to add titles to TabLayout (see the documentation of TabLayout.setTabsFromPager: https://developer.android.com/reference/android/support/design/widget/TabLayout.html#setTabsFromPagerAdapter(android.support.v4.view.PagerAdapter) )
Comment 3 imgx64+bz 2015-07-13 05:55:59 UTC
As a workaround until this gets fixed, you can override GetPageTitleFormatted. This is how it's done in the Xamarin Cheesesquare demo app (https://github.com/xamarin/monodroid-samples/blob/master/android5.0/Cheesesquare/MainActivity.cs#L115 ):

>public override Java.Lang.ICharSequence GetPageTitleFormatted (int position)
>    return new Java.Lang.String (fragmentTitles [position]);
Comment 4 Atsushi Eno 2016-08-08 07:38:25 UTC
It is not only the workaround but is the actual solution; the Java method that needs to be overriden is the one that takes CharSequence (otherwise there would be big confusion between the utility overload that takes string and the actual body of the actual interoperating Java method).