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

Google Account login Integration for android Xamarin

$
0
0

I need to integrate google login to android application. gone through the code from bellow link:
http://motzcod.es/post/67077106339/google-plus-services-login-and-1-in-xamarin-android
it shows the error connection failed and [GooglePlayServicesUtil] Google Play Store is missing. even ofter adding google play service(Froyo) component.

even i gone through the bellow links
https://developers.google.com/+/mobile/android/sign-in
http://stackoverflow.com/questions/18706519/android-login-using-google-account
http://stackoverflow.com/questions/15266669/google-login-for-android-app

but this is related to android eclipse using java code. can anybody suggest me how to do this in xamarin. any hints/links are appreciated. thank you.


How to move a Map pin on android

$
0
0

Map pins are not moving by changing their lat, lon on android. Does anyone knows how to do it elegantly? How to call setposition android method on the pin?

How to change quantity of listview item on button click?

$
0
0

I have a listview with a item title label, a button and entry,when a user click on listview items button then it will increase the quantity of selected list item?

how to do this?

Tableview - disallow row selection

$
0
0

I have a tableview which I'm using for a settings page. This tableview contains a row with a switch. I would like to disable the selection of the row containing the switch, while keeping the switch (or other child controls) enabled. I'm hoping there is an easy way to accomplish this without custom code.

I've provided a couple of pictures for illustration. Please disregard the alignment of the switch control to the text. It will be fixed. Thanks.

Get nested Json

$
0
0

hi guys
I want to get nested json and use them in listview
this is my property class

 public class Items
    {
        public Image  image { get; set; }
        public Artist artist { get; set; }
    }


    public class Rootobject
    {
        public Tracks tracks { get; set; }
    }

    public class Tracks
    {
        public Track[] track { get; set; }
        public Attr attr { get; set; }
    }

    public class Attr
    {
        public string page { get; set; }
        public string perPage { get; set; }
        public string totalPages { get; set; }
        public string total { get; set; }
    }

    public class Track
    {
        public string name { get; set; }
        public string duration { get; set; }
        public string playcount { get; set; }
        public string listeners { get; set; }
        public string mbid { get; set; }
        public string url { get; set; }
        public Streamable streamable { get; set; }
        public Artist artist { get; set; }
        public Image[] image { get; set; }
    }

    public class Streamable
    {
        public string text { get; set; }
        public string fulltrack { get; set; }
    }



    public class Image
    {
        public string text { get; set; }
        public string size { get; set; }
    }

    public class Artist
    {
        public string name { get; set; }
        public string mbid { get; set; }
        public string url { get; set; }
    }

and this is my MainPage.cs
but this code is not working with nested json

private async void OnGetJson()
        {
            try
            {
                if (CrossConnectivity.Current.IsConnected)
                {

                    _activityIndicator.IsRunning = true;
                    var uri = new Uri("**************~~~~e7d9d6&format=json");
                    var client = new HttpClient();
                    var content = await client.GetStringAsync(uri);
                    string a = content.ToString();
                    var tr = JsonConvert.DeserializeObject<List<Items>>(a);
                    ObservableCollection<Items> ob = new ObservableCollection<Items>(tr);
                    lister.ItemsSource = ob;


                    int i = ob.Count;
                    if (i > 0)

                    {
                        _activityIndicator.IsRunning = false;
                    }
                    i = (ob.Count * heightRowsList);
                    _activityIndicator.HeightRequest = i;
                }
                else
                {
                    await DisplayAlert("Error", "No Connection", "Cancel");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }

Can Anyone help?

Debug only Gesture

$
0
0

Does anyone have a suggestion on how to add a debug only gesture. Something accessible on any page.
I thought about adding something that would recognize a tap on the title. But that wouldn't work on modal pages.
Perhaps a double tap on the page. But it appears that isn't easy to do without adding a third party library.

We want to have a way, in Debug only, to bring up some info on the current page. So it is perfectly fine for it to be "hidden UI" and non intuitive.

How to remove previous page after pushing a modal page?

$
0
0

List Page -> Detail Page -> Edit Page (Modal page)

How can I remove detail page after pushing edit page modally? if I check Navigation.NavigationStack on OnAppearing method of edit page, it doesnt know anything about detail page because NavigationStack has only Edit Page but no List Page, no Detail Page? so what is the best way to achieve this?

Android: How do I keep my Editor from scrolling below keyboard when moving the cursor?

$
0
0

I've got an Editor which is tall enough to accommodate multiple lines of input. The editor is at the bottom of the screen. Once multiple lines are entered, if you move the cursor up a line, the entire view shifts downward, so the line you just left is now obscured by the keyboard. I'd like it to not do this unless the line the cursor is on is either off screen or close to being off screen. Sort of like how the built in Android message app works. Here's what I mean in pictures.


Default state, everything looks good. We have 3 lines of input


I move the cursor up one line (either with keyboard arrow keys or just by dragging that purplish teardrop shaped handle upward): notice that the entire view has shifted down one line and so "line 3" is now obscured. I don't want this behavior (it among other things hides some UI elements).

This is the Android messaging app. This is the behavior I want: when you move the cursor to that next line, the view doesn't just shift downward. If you have enough lines to scroll past the visible area, Android just shifts the text and not the entire view to accommodate it.

What I noticed is that if I move my control up to like the middle of the screen instead of being at the bottom, then this behavior doesn't happen: moving the cursor upward doesn't scroll my editor until it's appropriate, like I want to. So why is it that because my editor is at the bottom of the screen, this behavior doesn't happen? The keyboard pans the entire screen upward.


Native Forms on Android

$
0
0

I am trying to experiment with Native Forms in XF. I have this in iOS working right. That is fine.

In Android, I am getting the following error:

'MainPage' does not contain a definition for 'CreateSupportFragment' and the best extension method overload 'PageExtensions.CreateSupportFragment(ContentPage, Context)' requires a receiver of type 'ContentPage'

The code is erroring in the following code:
var _cp = new MainPage(); // my page from XF.
_list = _cp.CreateSupportFragment(this);

I have made sure that my nuget packages are up to date. I have cleaned and compiled. I've done a bunch of things, but alas, no love. Any ideas on this?

TIA

Why xamarin map custom pin move?

$
0
0

i made custom pin in xamarin map.

and make 20 custom pins.

but pins are move somtimes and disappear and appear.

Why custom pin move and disappear?

please help me...

A little question about bar background color

$
0
0

already set the navigation bar background color to Cyan, when i run it to emulator it is showing correctly but after creating apk file and install it to my android phone then navigation bar background color is showing white.so what is wrong with this? how is it possible?and how to solve this?

I am using visual studio 2015 14.0 and xamarin version is 4.7.10

why xamarin map marker is disappear and appear for few seconds?

$
0
0

I made 20 marker in xamarin map. but in the map there are showen less than 20 marker maybe 8~10 marker only showed in map.

showing the map, disappeared marker show few seconds and disappear again.

i don't know why this situation occur.

down link is i captured video.

image

please help me

ListView.ScrollTo not working in UWP

$
0
0

I'm trying to scroll down to the last item of a ListView by calling a System.Action "refreshScrollDown()" in my ViewModel, which then gets handled in the code-behind of my xaml:

ViewModel:
refreshScrollDown ();

xaml.cs:

ViewModel.refreshScrollDown = () => {
    if (ViewModel.Messages.Count > 0) {
        Device.BeginInvokeOnMainThread (() => {

            ListViewMessages.ScrollTo (ViewModel.Messages [ViewModel.Messages.Count - 1], ScrollToPosition.End, true);
        }); 
    }
};

This works on iOS and Android, but not on UWP. Rarely it will scroll to the bottom, but most of the times it won't. There is no exception.

Does anyone have an idea how I could work on it? Suggestions are appreciated. Thank you!

EDIT: If I use ScrollTo just at the point where I added an item to the ListView, it will scroll. What's not working is uploading the message to the server, then refreshing my ListView and THEN trying to scroll in UWP.

using.NETFramwork, Version=v4.6.1' instead of the project target framwork' .NETStandard,Version=v2.0

$
0
0

i have a old project which is develop in 2017 and it work fine in 2017 on other pc , but when it move another pc which have also vs 2017 it give me errpor in some package i dont understand why it come and how to solve it ? the error is mention blow.

Package was restored using.NETFramwork, Version=v4.6.1' instead of the project target framwork' .NETStandard,Version=v2.0'. THis package may not be fully compatible with your project.

Can't authorize to Web api access token

$
0
0

Hello,
I have this code

 using (var client = new HttpClient())
        {              
            try
            {
                AuthenticationResult ar = await App.PCA.AcquireTokenSilentAsync(App.Scopes, GetUserByPolicy(App.PCA.Users, App.PolicySignUpSignIn), 
            App.Authority, false);
                string token = ar.AccessToken;
                HttpRequestMessage req = new HttpRequestMessage
                {
                    Content = new StringContent(request, Encoding.UTF8, "application/json"),
                    Method = HttpMethod.Delete,
                    RequestUri = uri
                };
                client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
                var response  = await client.SendAsync(req);

                if (response.IsSuccessStatusCode)
                {                       
                    return;
                }

            }
            catch (Exception ex)
            {
                Debug.WriteLine($"{ex.StackTrace}{Environment.NewLine}{ex.Message}");
                throw ex;
            }
        }

And as I call to my API the call is returned saying error : "not authorized". How is this possible as I have sent my access token with the headers. Tried to set the headers in client and in httprequestmessage both with no success.
Any ideas or solutions?


CFBundleLocalizations in App Language

$
0
0

Hi fellas,

As you know on iOS platform. There is a couple of this to locatization like "Use Photo" or "Retake" if you add following kind of line in your info.plist these text comes from your phone language. After the adding these lines locatization basicly depends of your phone language. Do you know any solutions for this localization depands of your current app language ?

<key>CFBundleLocalizations</key> <array> <string>en</string> <string>nl</string> </array> <key>CFBundleDevelopmentRegion</key> <string>Dutch</string>

Multiple projects with the same XAML files

$
0
0

I have a few apps that have similar views, with different branding. How can I reuse the same XAML files?

Is it possible (easy?) to change the background color on a Xamarin.Forms Android Date Picker?

$
0
0

Is it possible (easy?) to change the background color on a Xamarin.Forms Android Date Picker? Right now it is hot pink. Ugh.

Missing templates

$
0
0

I'm missing an option to create Resource Dictionary on my Add window.

On my visual studio installer I have "Mobile development with .NET" installed.

Just in case this are the other things installed

  • .NET desktop development
  • Desktop development with C++
  • ASP.NET and web development
  • Visual Studio Extension

System.InvalidCastException on the Main.cs IOS

$
0
0

I am getting this exception System.InvalidCastException on IOS, and my Android project runs fines

here is the stake track:

" at Xamarin.Forms.Platform.iOS.NavigationRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00007] in :0 \n at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in :0 \n at Xamarin.Forms.Platform.iOS.NavigationRenderer.CreateViewControllerForPage (Xamarin.Forms.Page page) [0x00008] in :0 \n at Xamarin.Forms.Platform.iOS.NavigationRenderer+d__45.MoveNext () [0x00016] in :0 \n--- End of stack trace from previous location where exception was thrown ---\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.1.28/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152 \n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.1.28/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 \n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.1.28/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 \n at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.1.28/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 \n at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.1.28/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357 \n at Xamarin.Forms.Platform.iOS.NavigationRenderer+<b__40_0>d.MoveNext () [0x00067] in :0 \n--- End of stack trace from previous location where exception was thrown ---\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.1.28/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152 \n at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.1.28/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018 \n at UIKit.UIKitSynchronizationContext+c__AnonStorey0.<>m__0 () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.1.28/src/Xamarin.iOS/UIKit/UIKitSynchronizationContext.cs:24 \n at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.1.28/src/Xamarin.iOS/Foundation/NSAction.cs:163 \n at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)\n at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.1.28/src/Xamarin.iOS/UIKit/UIApplication.cs:79 \n at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.1.28/src/Xamarin.iOS/UIKit/UIApplication.cs:63 \n at MyScooterDrinks.iOS.Application.Main (System.String[] args) [0x00002] in /Users/siphomario/Desktop/MyScooterDrinks/myscooterdrinks/MyScooterDrinks/MyScooterDrinks.iOS/Main.cs:19 "

Viewing all 58056 articles
Browse latest View live


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