Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 58056 articles
Browse latest View live

Remove icon from action bar from xamarin forms android project

$
0
0

Hi,
Can someone help me in removing icon from action bar ?

Thanks,
Ashish jha


Help! This is Hell! Is the Xamarin Team listening?

$
0
0

I have an Android app I developed about a year ago on Xamarin Forms in VS2015. I checked it out to make some minor modifications, but I had reloaded Windows 10 since then. I fired up a completely fresh Windows 10 installation, installed VS2015 and ran Windows Update. I loaded the App code base and updated the NuGet packages (these are all Xamarin. ... packages, nothing unusual or third-party). I loaded the Oreo API in API Manager and took all the updates offered. When I rebuilt the code base, it completed without errors, but there were a couple of worrying messages:

Multiple instances of CS0618: Forms.Context is obsolete ...

"No way to resolve conflict between "mscorlib, Version=4.0.0.0, ... and "mscorlib, Version=2.0.5.0 ... Choosing mscorlib, Version=4.0.0.0 ... arbitrarily."

The last is in output only, neither an error or warning, but it sounds really bad, and choosing code arbitrarily is rarely the right thing to do in software!

Since there were no actual errors I went ahead to debug on a real ADB target (A Lenovo Tablet, Android 6.0 - API 23). The app loads up and presents an empty screen and then terminates on an exception before executing any of my code:

Java.Lang.RuntimeException: Unable to instantiate activity ComponentInfo ... Didn't find class "md59dfe07309ceba9bfe71a67493c5725be.MainActivity" on path: DexPathList[[zip file ...

I have no idea how to proceed and have tried everything I can think of including deleting everything Xamarin, Mono and App related from the tablet, deleting the bin and obj directories and re-building, reverting the code base and trying both before and after updating NuGet packages. None of this made any difference, though in the course of all this faffing about the app did successfully run on one occasion which I could not repeat.

Please, I am getting desperate, does anyone have any kind of handle on this or any suggestion as to how I can proceed?

Xamarin.Forms 2.3.4.270

$
0
0

We've published service release 2.3.4.270 to address a priority issue with PopAsync, RemovePage, and Android Support Libraries API 25.1.1.

Release Notes

If you have a bug to report, drop us a detailed report here so we can investigate.

How to set initial text (and be able to change it) in an EntryCell?

$
0
0

According to the documentation, an EntryCell's Text property is described as "the initial text that will appear in the editor." However, when I do this in xaml:

Text="{Binding Name}";

I notice that the text in the EntryCell is not actually editable when I run the app. The EntryCell's purpose is to rename an object. I'd like the initial text in the EntryCell to be the object's original name, so that it is easy to modify. We're currently using a Placeholder binding, which is helpful, but only shows the name when there is no text entered.

Any suggestions for me? I have also looked for an event like "Focused" so that I can set the text when someone starts to edit the name field, but I don't see any such event. Btw, I'm a Xamarin newb, so maybe there's a simple answer that has escaped my searches so far.

How to implement Video Interstitial Ads of Google AdMob in Xamarin.Forms?

$
0
0

Hi everybody!
As the title, How to implement Video Interstitial Ads of Google AdMob in Xamarin.Forms?
Thank you!

Why can't I clear the TextDecoration in Xamarin Forms UWP App?

$
0
0

Using Xamarin Forms (version 2.5.0.121934), I'm working on an app targeting Android, iOS, and UWP. I need to add underlining and strikethrough to some text, which require custom renderers. For Android and iOS, everything is working fine, and on UWP, applying strikethrough or underline works correctly, but removing those decorations isn't working.

Here's the entirety of the UWP renderer:

[assembly: ExportRenderer(typeof(EnhancedLabel), typeof(EnhancedLabelRenderer))]
namespace myApp.UWP
{
    public class EnhancedLabelRenderer : LabelRenderer
    {
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            var strikethrough = ((EnhancedLabel)sender).Strikethrough;
            var underline = ((EnhancedLabel)sender).Underline;

            if (strikethrough && underline)
            {
                Control.TextDecorations = TextDecorations.Strikethrough | TextDecorations.Underline;
            }
            else if (strikethrough)
            {
                Control.TextDecorations = TextDecorations.Strikethrough;
            }
            else if (underline)
            {
                Control.TextDecorations = TextDecorations.Underline;
            }
            else
            {
                Control.TextDecorations = TextDecorations.None;
            }
        }
    }
}

EnhancedLabel is a simple class that extends Xamarin.Forms.Label and adds the simple BindableProperty fields that specify strikethrough or underlining.

The renderer is properly setting TextDecorations.None, but that isn't being reflected on the UI. I've worked through this in the debugger, and can actually see that the state of the TextBlock within the ExtendedLabel has TextDecorations.None, but the UI is still drawing it with underlining or strikethrough (essentially, either of those can be added, but neither can be removed).

I've gone through the Xamarin documentation and looked at the bugs in Bugzilla, and haven't found any clues. Has any one else encountered this? Wondering if there's a UWP-specific call I need to make that I missed, or if using TextDecorations is the wrong way to apply the styles, or if I've actually stumbled across a bug.

PostAsync is not working properly, whenever executed it gives exception in the catch.

$
0
0

Hi guys,
I'm having problem executing "PostAsync" as it is giving unusual error, My whole code works fine except the line with "PostAsync". The weird thing is that , it posts the content to the database through PostAsync successfully but then jumps to "Catch" and throws exception. I have given my code below, what am I doing wrong..?

FYI: I'm using Xamarin.Forms and the database is Sharepoint list

try
{
using (var client = new HttpClient()
{ Timeout = TimeSpan.FromSeconds(5) })
using (var content = new MultipartFormDataContent())
{
var values = new[]
{
new KeyValuePair<string, string>("PinCode", pincode),
new KeyValuePair<string, string>("Email", email),
new KeyValuePair<string, string>("FirstName", firstname),
new KeyValuePair<string, string>("MiddleName", middlename),
new KeyValuePair<string, string>("FamilyName", familyname)

                       };                       

                    foreach (var keyValuePair in values)
                        content.Add(new StringContent(keyValuePair.Value), keyValuePair.Key);

                   using (var result = await client.PostAsync(requestUri, content).ConfigureAwait(false))  //App Jumps to Catch and don't execute further
                       {
                            var input = await result.Content.ReadAsStringAsync().ConfigureAwait(false);

                            if (result.IsSuccessStatusCode)
                            {
                                await DisplayAlert("Response:>", result.StatusCode.ToString(), "OK");
                                submit.IsEnabled = false;
                            }
                            else await DisplayAlert("Response:>", "Unsuccessful", "OK");
                       }
                }                
        }
        catch (TaskCanceledException ex)
        {
            if (ex.CancellationToken.IsCancellationRequested == false)
            {  await DisplayAlert("ex", "Unsuccessful", "OK");   }
            else
            { await DisplayAlert("ex", "true~~~~", "OK");  }

}

How do I make my app remember my last language selected when I quit the app..?

$
0
0

Hi guys,

I am working on an app with 2 different languages ( English and Arabic ), For now, the app checks the mobile language and based on that it opens either Arabic and English, but lets say I have English set as my Mobile Language (Default) and I change the language of the App to Arabic, when I'll exit the app and reopen, it will open English not Arabic, but I want my app to remember the last language selected and based on that open the app.

any guidance will be much appreciated.


how to Find a View by type in my custom renderer for Android? C# Beginner

$
0
0

I want to get this Object {Xamarin.Forms.Platform.Android.ListViewRenderer} to set an IOndrag listener on It

Im looping through all the views in main activity like so:

my problem is that I see the result when I DEBUG but i dont know how to access it : I want to return the ViewRenderer object and do do some stuff with it

// I pass rv to getAllChildren() function and Im able to find all the subViews of mainActivity (around 4000 object found)

var rv =(ViewGroup) v.RootView;
Queue<Android.Views.View> ChildList = getAllChildren(rv);

private Queue<Android.Views.View> getAllChildren(Android.Views.View v){

        Queue<Android.Views.View> visited = new Queue<Android.Views.View>();
        Queue<Android.Views.View> unvisited = new Queue<Android.Views.View>();
        Queue<Android.Views.View> onlylistView = new Queue<Android.Views.View>();


        if (v.IsAttachedToWindow && !v.Equals(null)) unvisited.Enqueue(v);

        while (unvisited.Count != 0 )
        {

            Android.Views.View TheView = unvisited.Dequeue();

            visited.Enqueue(TheView);


            if (TheView is ViewGroup && (TheView as ViewGroup).ChildCount > 0)
            {
                var viewGroup = TheView as ViewGroup;
                for (int i = 0; i <= viewGroup.ChildCount; i++)
                {
                    if (viewGroup.GetChildAt(i) == null)
                        continue;
                    else
                        unvisited.Enqueue(viewGroup.GetChildAt(i));
                }
            }
            else if (TheView is Android.Views.View )
            {
                var view = TheView as Android.Views.View;

                if (view.GetType() == typeof(ViewRenderer)) {

                        onlylistView.Enqueue(view);

                    break;

                }
                    visited.Enqueue(view);
            }

        }

        return onlylistView;
    }

How to change the IsVisible for the ContentPage at runtime?

$
0
0

Hi,

I am setting the IsVisible="false" for the ContentPage in my XAML.

I want to know how can I change it to true at runtime?

Here is my XAML:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="Eithar.Home" IsVisible="false"
    .................
    .................
    .................
    .................

Thanks,
Jassim

Connection timed out from REST Webservice

$
0
0

I am using Xamarin forms with REST webservice. If my service is down, how will check that in login page.
public async static Task validtoken{
HttpClient client = new HttpClient(); var result = await client.GetStringAsync(uri);;} it just hang there. Not throwing any exception also for sometime. How to check whether my client is active or down with this.
Shermin

UnhandledException on calling PopModalAsync

$
0
0

Hello,
In my UWP project, I have a main Page and want to show a modal page when user click on a ViewCell of a TableView menu.

Here is the code in the MainPage :
public async void m_vcPoleAdd_Tapped(object p_objSender, EventArgs p_eaArgs) { await Application.Current.MainPage.Navigation.PushModalAsync(new pgeEditPole()); }
Everything works fine, the modal Page is shown ...

... and when the user has finished to fill the formular, then I want to go back on the main page, so I think I have to use that code in the modal page :
public async void m_vcQuit_Tapped(object p_objSender, EventArgs p_eaArgs) { await Application.Current.MainPage.Navigation.PopModalAsync(); }
... but an unhandled exception is raised !

Can somebody help me find the root of the problem?

The problem doesnt arrives on Android platform !

Thank you in advance

Metadata file *.dll could not be found + ResolveLibrary Projects task failed unexpectedly

$
0
0

Please help me anybody with these problems for PCL project.
Before compilation:

After compilation:

I had done 7 steps from description of IDE0006 and found it:

I tried to reluild project, to downgrade Android.Support packages, to create project for anew, to reinstall Visual Studio but all this does not give a result.
I'm desperate! The time is ticking, the deadline is approaching, and I have not been able to fix it for 4 days.
If you need, I can send solution.

Auto Logout in Azure B2C Xamarin Forms

$
0
0

I'am already implementing login using azure b2c from xamarin forms and it works fine but there's a bug after 1 hours the users acces token will can not be used anymore and im guesing its because my b2c application cant use the refreshed token . Its because after 1 hours the token will be refreshed untill 14 days, anyone has experience this ? And im using Microsoft.Identity.Client version 1.0.304142221-alpha following from this github https://github.com/xamarin/xamarin-forms-samples . Is that beause bug from that version of Microsoft.Identity.Client ? and should i change for the latest version ?

Resizing Children in AbsoluteLayout on OnSizeAllocated

$
0
0

I made a control, that inherits AbsoluteLayout with the goal to position n children elements in a certain way.
It sets custom x and y positions and custom width and an AutoSized height (up to a certain maximum height).
Basically, my control works like this:

public class ResponsiveLayout : AbsoluteLayout
    {
    protected override void OnSizeAllocated(double width, double height)
        {
        foreach (var control in Children)
                {
            var size = control.Measure(elementWidth, AutoSize);
            var measuredHeight = size.Request.Height;
             if (MaxPanelHeight != AutoSize && measuredHeight > MaxPanelHeight)
                measuredHeight = MaxPanelHeight;

            SetLayoutBounds(control, new Rectangle(posX1, posY1, elementWidth, measuredHeight));
        }
    }
}

Ideally, this should be called every time the Children changed (added/removed) and every time the size of the control changes (the phone changes orientation / the Window changes size).

The problem is, this get's called way too often. Every window resize, OnSizeAllocated get's called roughtly 3 times per child control - which causes quite a performance issue on Android. For other events (measure, invalidated, and so on) it's the same deal.

Is there a way to just call this once and make it work?
Like, is there an event that fires only when the last child did invalidate or something?


ACR user dialogs not working on viewmodel

$
0
0

Dears,

I am using ACR user dialogs to show load progress in the UI. It is working fine in my cs files. But in viewmodel class it is not working.
In my android mainactivty I am initializing the ACR user dialogs and show and hide the userdialoges in class files.
My code:
Initialization:

   UserDialogs.Init(this);

For Showing Progress:

  UserDialogs.Instance.ShowLoading();

For hiding progress:

  UserDialogs.Instance.HideLoading();

How I can show the load progress in viewmodel class, please suggest a solution for this :)
Thanks in advance :)

Android manifest permissions don't match the ones asked during install

$
0
0

In my AndroidManifest i have set the following permissions:

uses-permission android:name="android.permission.INTERNET"
uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"
uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
uses-permission android:name="android.permission.VIBRATE"

When installing the apk I need to approve the following permissions:

Approximate location (network-based)
Precise location (GPS and network-based)
Modify or delete the contents of your SD card ------------WTF?

Full network access
Control Vibration
Test access to protected storage ---------WTF?

I'm guessing that one of the packages I'm using requires these permissions, but it's not very clear which one that uses that.
ExifLib.PCL
Microsoft.Bcl
Microsoft.Bcl.Build
Microsoft.Bcl.Compression
Microsoft.Net.Http
Newtonsoft.Json
NUnit
Xam.Plugin.Geolocator
Xam.Plugin.Settings
Xamarin.Android.Support.Design
Xamarin.Android.Support.v4
Xamarin.Android.Support.v7.AppCompat
Xamarin.Android.Support.v7.CardView
Xamarin.Android.Support.v7.MediaRouter
Xamarin.Forms
Xamarin.Forms.Maps
Xamarin.GooglePlayServices.Ads
Xamarin.GooglePlayServices.Analytics
Xamarin.GooglePlayServices.AppIndexing
Xamarin.GooglePlayServices.Base
Xamarin.GooglePlayServices.Basement
Xamarin.GooglePlayServices.Maps
Xamarin.Insights
Xlabs.Core
Xlabs.Forms
Xlabs.IoC
Xlabs.Platform
Xlabs.Serilazation

And the Component Json.NET

Is there anyone that knows why it's like this?

Also in Android 6.0 I have implemented the Request permissions, and I have not encountered any problems by not asking for the SD card in the app. I'm doing the question on GPS and that works as expected.

IOS StatusBar

$
0
0

Hello,
I have a question about my Forms project. When I start my application on an iPad / iPhone, I have a light gray bar at the top - how can I remove it?
I have tried a lot, unfortunately without success.
Thank you very much

How to handle Multi-Touch events with SkiaSharp?

$
0
0

Skiasharp enables to manipulate touch events with the method:
private void OnTouch(object sender, SKTouchEventArgs args)

With this method I can handle only one touch point coordinates:
args.Location.X, args.Location.Y

But how can I detect multitouch event?

the android native api for example enables you to manage two finger locations in order to detect multitouch.

How can I achieve that with SkiaSharp?

App Crash before any pages are shown

$
0
0

12-14 12:23:45.371 I/MonoDroid(15558): UNHANDLED EXCEPTION:
12-14 12:23:45.391 I/MonoDroid(15558): System.NullReferenceException: Object reference not set to an instance of an object.
12-14 12:23:45.401 I/MonoDroid(15558): at Xamarin.Forms.Platform.Android.AppCompat.Platform.LayoutRootPage (Xamarin.Forms.Page page, System.Int32 width, System.Int32 height) [0x0000c] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:291
12-14 12:23:45.401 I/MonoDroid(15558): 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) [0x00003] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:199
12-14 12:23:45.401 I/MonoDroid(15558): at Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x0000e] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\PlatformRenderer.cs:73
12-14 12:23:45.401 I/MonoDroid(15558): 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 :0
12-14 12:23:45.401 I/MonoDroid(15558): at (wrapper dynamic-method) System.Object:ebcd43d0-aa20-451f-a47f-5eba3bbba10c (intptr,intptr,bool,int,int,int,int)
12-14 12:23:45.431 W/art (15558): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
12-14 12:23:45.441 D/Mono (15558): DllImport searching in: '__Internal' ('(null)').
12-14 12:23:45.441 D/Mono (15558): Searching for 'java_interop_jnienv_throw'.
12-14 12:23:45.441 D/Mono (15558): Probing 'java_interop_jnienv_throw'.
12-14 12:23:45.441 D/Mono (15558): Found as 'java_interop_jnienv_throw'.
An unhandled exception occured.

Any ideas?

Viewing all 58056 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>