xabre / xamarin-forms-tab-badge Goto Github PK
View Code? Open in Web Editor NEWXamarin Forms bindable Tab badges for iOS, Android, UWP, MacOS and WPF
License: MIT License
Xamarin Forms bindable Tab badges for iOS, Android, UWP, MacOS and WPF
License: MIT License
Hi, i recently have this issue, with iOS 10.2.1
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'BadgedTabbedPageRenderer'. at Foundation.NSObject.get_SuperHandle () <0x100d5f400 + 0x00080> in <d9a64a30a9e54cff99bd5519750ca6b8#bb7dfffeb7c9e3019dd7cb5c249b3d5e>:0 at UIKit.UITabBarController.get_TabBar () <0x100dde960 + 0x00063> in <d9a64a30a9e54cff99bd5519750ca6b8#bb7dfffeb7c9e3019dd7cb5c249b3d5e>:0 at Plugin.Badge.iOS.BadgedTabbedPageRenderer.OnTabbedPagePropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) <0x1017e5e78 + 0x000d3> in <2c4e40e8cf034676be16fd0371fe46c8#bb7dfffeb7c9e3019dd7cb5c249b3d5e>:0 at (wrapper delegate-invoke) <Module>:invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) <0x10075a768 + 0x0004f> in <bf304fc411724e23a42595b76799a13a#bb7dfffeb7c9e3019dd7cb5c249b3d5e>:0 at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) <0x1007b07d8 + 0x00027> in <bf304fc411724e23a42595b76799a13a#bb7dfffeb7c9e3019dd7cb5c249b3d5e>:0 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.BindableObject+SetValueFlags attributes, System.Boolean silent) <0x10075bc38 + 0x001bb> in <bf304fc411724e23a42595b76799a13a#bb7dfffeb7c9e3019dd7cb5c249b3d5e>:0 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.BindableObject+SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) <0x10075b190 + 0x00213> in <bf304fc411724e23a42595b76799a13a#bb7dfffeb7c9e3019dd7cb5c249b3d5e>:0 at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) <0x10075fbdc + 0x004af> in <bf304fc411724e23a42595b76799a13a#bb7dfffeb7c9e3019dd7cb5c249b3d5e>:0 at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) <0x10075f940 + 0x00077> in <bf304fc411724e23a42595b76799a13a#bb7dfffeb7c9e3019dd7cb5c249b3d5e>:0 at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 () <0x100760c6c + 0x00017> in <bf304fc411724e23a42595b76799a13a#bb7dfffeb7c9e3019dd7cb5c249b3d5e>:0 at Foundation.NSAsyncActionDispatcher.Apply () <0x100d60910 + 0x00023> in <d9a64a30a9e54cff99bd5519750ca6b8#bb7dfffeb7c9e3019dd7cb5c249b3d5e>:0 at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) <0x100d43738 + 0x0009b> in <d9a64a30a9e54cff99bd5519750ca6b8#bb7dfffeb7c9e3019dd7cb5c249b3d5e>:0 at PayIt.iOS.Application.Main (System.String[] args) <0x100433270 + 0x0001b> in <dc39009bbb1f4e7ab78024b4f3697932#bb7dfffeb7c9e3019dd7cb5c249b3d5e>:0
Having a crash on start up with android. iOS is working fine.
The android example is also working fine. What do I wrong?
Code:
CustomRenderer:
[assembly: ExportRenderer(typeof(MainPage), typeof(MyTabbedPageRenderer))] namespace Appviseurs.Droid { public class MyTabbedPageRenderer : BadgedTabbedPageRenderer { private MainPage page; private Activity activity; .....
Mainpage:
<?xml version="1.0" encoding="utf-8" ?> <TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:plugin="clr-namespace:Plugin.Badge.Abstractions;assembly=Plugin.Badge.Abstractions" x:Class="Appviseurs.Views.TabbedPage.MainPage"> </TabbedPage>
`private void SetMainPage()
{
InitializeComponent();
CreateNavigationPage(new DashboardPage(), "Dashboard", "ic_dashboard.png");
CreateNavigationPage(new ContactPage(), "Gesprekken", "ic_chat.png");
CreateNavigationPage(new InfoPage(), "Informatie", "ic_info.png");
CreateNavigationPage(new SettingsPage(), "Instellingen", "ic_settings.png");
BackgroundColor = Color.FromHex(DatabaseHandler.GetInstance().kantoor.PrimaryColor);
BarBackgroundColor = (Color)App.Current.Resources["backgroundNavigationBar"];
BarTextColor = Color.White;
}
private void CreateNavigationPage(object objectType, string title, string icon)
{
var navigationPage = new NavigationPage((Page)objectType);
navigationPage.Icon = icon;
navigationPage.Title = title;
if(title.Equals("Gesprekken"))
{
TabBadge.SetBadgeText(navigationPage, );
TabBadge.SetBadgeColor(navigationPage, Color.Red);
}
NavigationPage.SetHasNavigationBar(navigationPage, false);
Children.Add(navigationPage);
}`
Error:
FATAL EXCEPTION: main Process: ...., PID: 16282 android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object at Xamarin.Forms.Platform.Android.AppCompat.Platform.Xamarin.Forms.Platform.Android.IPlatformLayout.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00022] in <aa25dff89f734b22b9ab88fd01c78705>:0 at Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00018] in <aa25dff89f734b22b9ab88fd01c78705>:0 at Android.Views.ViewGroup.n_OnLayout_ZIIII (System.IntPtr jnienv, System.IntPtr native__this, System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00008] in <97e6692f30fe45028b1e0b834fcf308c>:0 at (wrapper dynamic-method) System.Object:000c410e-449f-4fa0-9d6d-2295bb8bd28f (intptr,intptr,bool,int,int,int,int) at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.n_onLayout(Native Method) at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.onLayout(PlatformRenderer.java:55) at android.view.View.layout(View.java:18798) at android.view.ViewGroup.layout(ViewGroup.java:5951) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079) at android.view.View.layout(View.java:18798) at android.view.ViewGroup.layout(ViewGroup.java:5951) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:18798) at android.view.ViewGroup.layout(ViewGroup.java:5951) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:18798) at android.view.ViewGroup.layout(ViewGroup.java:5951) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:18798) at android.view.ViewGroup.layout(ViewGroup.java:5951) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) at android.view.View.layout(View.java:18798) at android.view.ViewGroup.layout(ViewGroup.java:5951) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at com.android.internal.policy.DecorView.onLayout(DecorView.java:887) at android.view.View.layout(View.java:18798) at android.view.ViewGroup.layout(ViewGroup.java:5951) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2648) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2364) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1515) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7091) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927) at android.view.Choreographer.doCallbacks(Choreographer.java:702) at android.view.Choreographer.doFrame(Choreographer.java:638) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6682) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Hi,
I have downloaded the sample project which is available in "https://github.com/xabre/xamarin-forms-tab-badge". Then when i tried to run that app in iOS device, it is working fine. But in android, i am getting crash with out any reason. Can you guys please help us to resolve the issue and it should work perfectly in android devices too.
Thanks & Regards,
Manigandan V.
User should be able to change badge font attributes via binding:
I used this plugin for my project, and got 150+ following kind of warnings...
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2): Warning XA0106: Skipping JumpinMobile.Droid.Resource.Attribute.mediaRouteControllerSecondaryTextStyle. Please check that your Nuget Package versions are compatible. (XA0106) (JumpinMobile.Droid)
...
can't find TabLayout.SlidingTabStrip class when update api to 25.3.1
Updated to Xamarin Forms 3.1 and set the tabbar to be at the bottom just like on iOS. Badge is not working for Android, iOS works just fine.
download the source code from github yesterday.
And run the Plugin.Badge.Samle.Droid project, get the error.
01-09 12:36:20.074 I/MonoDroid(26905): at Android.Views.ViewGroup.GetChildAt (System.Int32 index) [0x00036] in :0
01-09 12:36:20.074 I/MonoDroid(26905): at Plugin.Badge.Droid.ViewExtensions.FindChildOfType[T] (Android.Views.ViewGroup parent) [0x0003a] in D:\xamarin-forms-tab-badge\Source\Plugin.Badge.Droid\ViewExtensions.cs:17
Allow the developer to specify margins which influence badge position.
Hi,
It crash on iOS9(iPhone 5) if I use setbadgecolor.
It's working fine on iOS10. (tested on iPhone 7)
I have a sample code that reproduce it.
Thanks.
I'd like to position a badge in the top-left position of the tab-text on Android, and I see that the BagdeView class has some support for this, I just can't figure out how and where to set it :)
How would I go about doing this?
Hi. Thanks for making this plugin. I am using your plugin in my Application, somehow it doesn't display on android. I have used bottom navigation bar plugin for display tabbar at bottom (i .e. this). I am using following code.
This is my tabbar page code.
<naxam:BottomTabbedPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:views="clr-namespace:Graysons.Views" xmlns:plugin="clr-namespace:Plugin.Badge.Abstractions;assembly=Plugin.Badge.Abstractions" x:Class="Graysons.Views.MainPage" xmlns:naxam="clr-namespace:Naxam.Controls.Forms;assembly=Naxam.Controls.Forms"> <TabbedPage.Children> <views:AddLocationPage/> <views:MenuPage/> <views:PromoPage/> </TabbedPage.Children> </naxam:BottomTabbedPage>
Now I have separate content page and it's code is :
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Graysons.Views.MenuPage" xmlns:local="clr-namespace:Graysons.Customs" xmlns:cc="clr-namespace:Graysons.Controls" xmlns:vm="clr-namespace:Graysons.ViewModels" xmlns:convertors="clr-namespace:Graysons.Convertors" xmlns:controls="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions" xmlns:resources="clr-namespace:Graysons.StringResources" xmlns:plugin="clr-namespace:Plugin.Badge.Abstractions;assembly=Plugin.Badge.Abstractions" Title="Menus" Icon="ic_menus.png" plugin:TabBadge.BadgeText="1" Style="{StaticResource CustomTopBar}"> <ContentPage.Padding> <OnPlatform x:TypeArguments="Thickness"> <On Platform="Android">0</On> <On Platform="iOS">0,20,0,0</On> </OnPlatform> </ContentPage.Padding> <ContentPage.Content> <StackLayout BackgroundColor="#F5F5F5"> ........................................................................... </StackLayout> <ContentPage.Content> </ContentPage>
How can I solve this. The issue is because of that plugin only. Without use of that plugin I can see the badge.
Allow customization of platform specific renderer settings:
Add a attached property for badge color.
Figure out how to prevent linker problems at assembly level. Linker please include is at app level.
I got a following exception for Android.
"System.InvalidCastException: Specified cast is not valid. Error"
If I comment out
[assembly: ExportRenderer(typeof(TabbedPage), typeof(BadgedTabbedPageRenderer))]
in AssembliInfo.cs, my project is no issue.
Do you know a way to resolve it?
Hi there,
After opening our app in the morning, the app crashed and it was related to badge so I report it here in case it might be useful.
The error was :
Cannot access a disposed object. Object name: 'BadgedTabbedPageRenderer'. @ iPad / 10.3.2 - :
at Foundation.NSObject.get_SuperHandle () <0x100a40140 + 0x000b0> in <58a9bd8a3cbb4d0092bc0a767ff66c0f#c1a6cf1187f05726b69010dae51380db>:0
at UIKit.UITabBarController.get_TabBar () <0x100a689f0 + 0x00063> in <58a9bd8a3cbb4d0092bc0a767ff66c0f#c1a6cf1187f05726b69010dae51380db>:0
at Plugin.Badge.iOS.BadgedTabbedPageRenderer.CheckValidTabIndex (Xamarin.Forms.Page page, System.Int32& tabIndex) <0x100e915d0 + 0x000af> in <afd8d9140eb740e59aa7f10157bc6de8#c1a6cf1187f05726b69010dae51380db>:0
at Plugin.Badge.iOS.BadgedTabbedPageRenderer.OnTabbedPagePropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) <0x100e91340 + 0x000a3> in <afd8d9140eb740e59aa7f10157bc6de8#c1a6cf1187f05726b69010dae51380db>:0
at (wrapper delegate-invoke) <Module>:invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) <0x100802960 + 0x00063> in <0f1ce60dbc6b4e24af01294c7acf41c6#c1a6cf1187f05726b69010dae51380db>:0
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) <0x10087dff0 + 0x00023> in <0f1ce60dbc6b4e24af01294c7acf41c6#c1a6cf1187f05726b69010dae51380db>:0
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.BindableObject+SetValueFlags attributes, System.Boolean silent) <0x100804460 + 0x00223> in <0f1ce60dbc6b4e24af01294c7acf41c6#c1a6cf1187f05726b69010dae51380db>:0
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.BindableObject+SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) <0x100803720 + 0x00393> in <0f1ce60dbc6b4e24af01294c7acf41c6#c1a6cf1187f05726b69010dae51380db>:0
at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) <0x1008098b0 + 0x005a3> in <0f1ce60dbc6b4e24af01294c7acf41c6#c1a6cf1187f05726b69010dae51380db>:0
at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) <0x1008095c0 + 0x0008f> in <0f1ce60dbc6b4e24af01294c7acf41c6#c1a6cf1187f05726b69010dae51380db>:0
at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 () <0x10080bde0 + 0x00023> in <0f1ce60dbc6b4e24af01294c7acf41c6#c1a6cf1187f05726b69010dae51380db>:0
at Foundation.NSAsyncActionDispatcher.Apply () <0x100a3c540 + 0x00023> in <58a9bd8a3cbb4d0092bc0a767ff66c0f#c1a6cf1187f05726b69010dae51380db>:0
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (intstring[]intptrintptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) <0x100a548e0 + 0x0002b> in <58a9bd8a3cbb4d0092bc0a767ff66c0f#c1a6cf1187f05726b69010dae51380db>:0
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) <0x100a54820 + 0x000ab> in <58a9bd8a3cbb4d0092bc0a767ff66c0f#c1a6cf1187f05726b69010dae51380db>:0
at Application.Main (System.String[] args) <0x1000319a0 + 0x001d7> in <22a26e2050ea498e9e0ddc60907a8be2#c1a6cf1187f05726b69010dae51380db>:0
Is it possible to put it on navbar?
Hi @xabre ,
I am using XF 3.1.
Setting up the Badgeposition as one of the enum values defined (https://github.com/xabre/xamarin-forms-tab-badge#badge-position) doesn't have any effect on the position of the Badge when rendered on iOS (11.4).
With XF 3.1, I have already reported in another bug that this badge plugin is crashing my Android version of the App.
Your help will be appreciated.
Thanks
Get ready for a 2.0 release targetting .NET Standard.
Thanks for the plugin. I am using your plugin and just customize my Tabbed page in iOS. Now the issue is badges are not updating. How can I update badge count while used custom tabrender in iOS?
My code is :
[assembly: ExportRenderer(typeof(TabbedPage), typeof(BottomTabbedPage))]
namespace Graysons.iOS.Renderers
{
public class BottomTabbedPage : TabbedRenderer
{
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
TabBar.UnselectedItemTintColor = UIColor.FromRGB(208, 208, 208);
TabBar.BackgroundColor = UIColor.White;
TabBar.Items[1].BadgeValue = "1";
TabBar.Items[2].BadgeValue = "1";
}
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
}
}
}
Would it be possible to change the position to bottom??
thx
How do you hide the badge if the value is 0? It does not auto hide if it has the value 0
Binding color doesn't seem to be a good idea since it doesn't work on iOS < 10
Getting this error on a Xamarin Forms app.
This was working until recent updates.
Xamarin Forms Version 2.3.4.231
Plugin.Badge Version 1.0.1
Java.Lang.ClassNotFoundException: Didn't find class "md5b6ca426d13ed509e21ee11c0a2720082.BadgedTabbedPageRenderer" on path: DexPathList[[zip file "/data/app/[identifier]-1/base.apk"],nativeLibraryDirectories=[/data/app/[identifier]-1/lib/x86, /data/app/[identifier]-1/base.apk!/lib/x86, /vendor/lib, /system/lib]]
at Java.Interop.JniEnvironment+Types.FindClass (System.String classname) [0x00137] in :0
at Java.Interop.JniType..ctor (System.String classname) [0x00007] in :0
at Java.Interop.JniPeerMembers+JniInstanceMethods..ctor (System.Type declaringType) [0x0006a] in :0
at Java.Interop.JniPeerMembers+JniInstanceMethods.GetConstructorsForType (System.Type declaringType) [0x0003a] in :0
at Java.Interop.JniPeerMembers+JniInstanceMethods.StartCreateInstance (System.String constructorSignature, System.Type declaringType, Java.Interop.JniArgumentValue* parameters) [0x00042] in :0
at Xamarin.Forms.Platform.Android.FormsViewGroup..ctor (Android.Content.Context p0) [0x00046] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android.FormsViewGroup\obj\Release\generated\src\Xamarin.Forms.Platform.Android.FormsViewGroup.cs:89
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement]..ctor () [0x00012] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:31
at Xamarin.Forms.Platform.Android.AppCompat.TabbedPageRenderer..ctor () [0x00007] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\TabbedPageRenderer.cs:29
at Plugin.Badge.Droid.BadgedTabbedPageRenderer..ctor () [0x0000b] in :0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:661
--- End of managed Java.Lang.ClassNotFoundException stack trace ---
;) support tab badges in UWP
Hi
Just recently added the badge package into my project but have encountered the following errors everytime I try to build:
Severity Code Description Project File Line Suppression State
Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Xamarin.Android.Support.Compat.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters) in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:line 225
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver) dribl.Android
I have modify your sample to first start on a page with a button.
When we click on the bouton it launches the tabbed page
In this case, the tab badge are not visibles.
In this case, the _tabLinearLayout have not children.
I am using the case legacy because my application is inherit form FormsApplicationActivity. and launch the projet Plugin.Badge.Sample.Droid.Legacy
How can we resolve it ?
I have debugged a little and the issue seems to be in
_tabLinearLayout = _tabLinearLayout ?? (rootGroup.GetChildAt(i) as ViewGroup)?.FindChildOfType()?.FindChildOfType();
the _tabLinearLayout never has children !! Why ???
Thank for your anser .
I have attached the sample android i have modified and snapshots of the screens
System.MissingMethodException: Method 'UITabBarItem.set_BadgeColor' not found.
getting this exception when trying to run this on IOS
(on android its working fine.)
have any ideas?
Thanx
Is there a way to hide/show all tabs?
Hi,
first of all very nice plugin. There is a problem on Android though.
My scenario is as follows(the names are for example purposes):
it's like the badges are bound to the BindingContext of the CurrentPage, not of the RootTabbedPage.
On iOS all is good. The scenario there is:
Custom Renderer for TabbedPage is not working anymore (Android). layout.TabCount stays 0. How the fix this?
Version Xamarin: latest
Version plugin: latest
[assembly: ExportRenderer(typeof(MainPage), typeof(MyTabbedPageRenderer))]
public class MyTabbedPageRenderer : BadgedTabbedPageRenderer
{
private ViewPager viewPager;
private MainPage page;
private Activity activity;
private bool setup;
private TabLayout layout;
public MyTabbedPageRenderer(Context context) : base(context) { }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (setup)
return;
if (e.PropertyName == "Renderer")
{
viewPager = (ViewPager)ViewGroup.GetChildAt(0);
layout = (TabLayout)ViewGroup.GetChildAt(1);
setup = true;
ColorStateList colors = Resources.GetColorStateList(Resource.Color.icon_tab, Context.Theme);
for (int i = 0; i < layout.TabCount; i++)
{
var tab = layout.GetTabAt(i);
var icon = tab.Icon;
if (icon != null)
{
icon = Android.Support.V4.Graphics.Drawable.DrawableCompat.Wrap(icon);
Android.Support.V4.Graphics.Drawable.DrawableCompat.SetTintList(icon, colors);
}
}
}
}
protected override void OnElementChanged(ElementChangedEventArgs<TabbedPage> e)
{
base.OnElementChanged(e);
activity = this.Context as Activity;
TabLayout layout = null;
page = (MainPage)e.NewElement;
for (int i = 0; i < ChildCount; i++)
{
var v = GetChildAt(i);
if (v is ViewPager)
viewPager = (ViewPager)v;
else if (v is TabLayout)
layout = (TabLayout)v;
}
if (layout != null)
{
for (int tabIndex = 0; tabIndex < layout.TabCount; tabIndex++)
SetTabIcon(layout, tabIndex);
}
try
{
viewPager.SetPageTransformer(false, new NoAnimationPageTransformer());
}
catch (Exception ex)
{
Utils.LogError(DateTime.Now + " - " + ex.Message + " " + ex.StackTrace);
}
}
private void SetTabIcon(TabLayout layout, int tabIndex)
{
var tab = layout.GetTabAt(tabIndex);
tab.SetText("");
switch (tabIndex)
{
case 0:
tab.SetIcon(Resource.Drawable.dashboard_icon);
break;
case 1:
tab.SetIcon(Resource.Drawable.gesprekken_icon);
break;
case 2:
tab.SetIcon(Resource.Drawable.info_icon);
break;
case 3:
tab.SetIcon(Resource.Drawable.instellingen_icon);
break;
}
}
}
}
MainPage:
public partial class MainPage : Xamarin.Forms.TabbedPage
{
public static readonly BindableProperty TabBarHiddenProperty = BindableProperty.Create("TabBarHidden", typeof(bool), typeof(MainPage), false);
public static int DashboardPage = 0;
public static int GesprekkenPage = 1;
public static int InfoPage = 2;
public static int SettingsPage = 3;
public static int TimelinePage = -1;
public bool TabBarHidden
{
get { return (bool)GetValue(TabBarHiddenProperty); }
set { SetValue(TabBarHiddenProperty, value); }
}
public MainPage()
{
Device.BeginInvokeOnMainThread(() =>
{
SetMainPage();
});
}
public MainPage(int page)
{
Device.BeginInvokeOnMainThread(() =>
{
SetMainPage();
SetCurrentPage(page);
});
}
private void SetMainPage()
{
InitializeComponent();
try
{
CreateNavigationPage(new DashboardPage(), "Dashboard", "dashboard_icon");
CreateNavigationPage(new ContactPage(), "Gesprekken", "gesprekken_icon");
CreateNavigationPage(new InfoPage(), "Informatie", "info_icon");
CreateNavigationPage(new SettingsPage(), "Instellingen", "instellingen_icon");
MessagingCenter.Subscribe<ContactPage, int>(this, "badgeCount", (sender, count) =>
{
SetBadge(count);
});
}
catch (Exception ex)
{
Utils.LogError(DateTime.Now + ": " + ex.Message + " - " + ex.StackTrace);
}
BarBackgroundColor = (Color)App.Current.Resources["backgroundNavigationBar"];
BarTextColor = Color.White;
}
private void CreateNavigationPage(object objectType, string title, string icon)
{
var navigationPage = new FontNavigationPage((Page)objectType);
navigationPage.Icon = icon;
navigationPage.Title = title;
navigationPage.BarBackgroundColor = (Color)App.Current.Resources["backgroundNavigationBar"];
navigationPage.BarTextColor = Color.White;
Children.Add(navigationPage);
}
public void SetBadge(int count)
{
if (Children.Count < 4)
return;
if (count == 0)
TabBadge.SetBadgeText(Children[1], "");
else
{
TabBadge.SetBadgeText(Children[1], count.ToString());
TabBadge.SetBadgeColor(Children[1], Color.Red);
}
}
public void SetCurrentPage(int page)
{
this.CurrentPage = Children[page];
}
public void OpenChatPage(ChatPage chatPage)
{
this.CurrentPage.Title = "";
this.CurrentPage.Navigation.PushAsync(chatPage);
}
}
Currently tabs badges are assigned statically when the tabbed page renderer is invoked. Enable the badegs to track their tabs if removed/reordered/added etc
I have come across an issue where the badges won't be displayed if the page displaying is embedded in a navigation page.
I am using prism for my app and got a demo project working perfectly, when I came to drop tab badge into my main app, I couldn't see any badges. I eventually tracked this issue down to 1 line of code, the navigation page. To demonstrate this issue I have recorded a little video of the bug in action (the password is "Xabre"). Hopefully this is helpful as I cannot share my source code and this should hopefully give you an insight into the issue.
As I said, my application is prism based however I cannot see this being an issue.
Would you please try "setBadgeTextAttributes:forState:"
for selector ?
Thank you :)
If you tried to hide the badge in the 'empty value' in the iOS, empty badge is displayed. On the other hand, it is hidden in Android.
Add XamarinForms MacOS support.
We have a dark tab background and would like to have a light BadgeColor. Without changing the TextColor the text would not be readable.
Hi there,
We get error on iOS 9 for text attribute. We saw documentation that this was not supported, but were not expecting the app to crash.
How would you recommend to handle iOS < 10 bindings?
Thanks.
Patrice
I have integrated this plugin in my app and works as expected, but now I want to show this tab bar at the bottom position in android, can anyone have some idea for that? I have tried this plugin, but a combination of this both plugin doesn't work. Please help me to get out of this task.
set the badge to 1232, then set the same badge to 1
By default the badge is lifted from the baseline. We would like to be able to position the badge at the baseline.
When I run plugin on Android API 15 devices, I got error: java.lang.NoSuchMethodError: no method with name='setBackground' signature='(Landroid/graphics/drawable/Drawable;)V' in class Landroid/widget/TextView
Its happens in BadgeView.cs line 97 - Background = _backgroundShape;
API Level 15 do not support method setBackground(Drawable), it was added in API Level 16. You can use SetBackgroundDrawable(Drawable) method instead.
Full log:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0
at Java.Interop.JniEnvironment+InstanceMethods.GetMethodID (Java.Interop.JniObjectReference type, System.String name, System.String signature) [0x0005b] in :0
at Java.Interop.JniType.GetInstanceMethod (System.String name, System.String signature) [0x0000c] in :0
at Java.Interop.JniPeerMembers+JniInstanceMethods.GetMethodInfo (System.String encodedMember) [0x00031] in :0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00045] in :0
at Android.Views.View.set_Background (Android.Graphics.Drawables.Drawable value) [0x00031] in :0
at Plugin.Badge.Droid.BadgeView.Init (Android.Content.Context context, Android.Views.View target) [0x000c1] in E:\Projects\xamarin-forms-tab-badge\Source\Plugin.Badge.Droid\BadgeView.cs:97
at Plugin.Badge.Droid.BadgeView..ctor (Android.Content.Context context, Android.Util.IAttributeSet attrs, System.Int32 defStyle, Android.Views.View target) [0x00020] in E:\Projects\xamarin-forms-tab-badge\Source\Plugin.Badge.Droid\BadgeView.cs:66
at Plugin.Badge.Droid.BadgeView..ctor (Android.Content.Context context, Android.Views.View target) [0x00000] in E:\Projects\xamarin-forms-tab-badge\Source\Plugin.Badge.Droid\BadgeView.cs:60
at PlanetVerify.Droid.Renderers.BadgedTabbedPageRenderer.AddTabBadge (System.Int32 tabIndex) [0x000c0] in /Users/a1/PV_repo/PlanetVerify/PlanetVerify.Droid/Renderers/BadgedTabbedPageRenderer.cs:62
at PlanetVerify.Droid.Renderers.BadgedTabbedPageRenderer+c__async0.MoveNext () [0x000c0] in /Users/a1/PV_repo/PlanetVerify/PlanetVerify.Droid/Renderers/BadgedTabbedPageRenderer.cs:149
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state) [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
at Android.App.SyncContext+<>c__DisplayClass2_0.b__0 () [0x00000] in :0
at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in :0
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in :0
at (wrapper dynamic-method) System.Object:dbd63dec-73dd-405b-a849-4a1b22c93df1 (intptr,intptr)
--- End of managed Java.Lang.NoSuchMethodError stack trace ---
java.lang.NoSuchMethodError: no method with name='setBackground' signature='(Landroid/graphics/drawable/Drawable;)V' in class Landroid/widget/TextView;
at mono.java.lang.RunnableImplementor.n_run(Native Method)
at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)
Is there a way to setup the tab height with this custom renderer?
Version: 2.0.0
UWP Version: Fall Creators Update
Visual Studio: 2017 15.7.3
I installed Plugin.Badge using the NuGet GUI to the PCL, iOS, Android and UWP-Project.
On Android and iOS everything works flawlessly, but I can't even export the renderer in the Assembly.cs of the UWP Project. The namespace Plugin.Badge.UWP is not even visible and so BadgeTabbedRenderer is not recognized.
What am I doing wrong?
Font size does not work properly for all platforms:
Android
iOS
UWP
Mac
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.