Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

How can I fix a view to the bottom of the parent regardless of the soft keyboard showing in Android

$
0
0

I have a view like so:

I am trying to get the Entry to appear right above the keyboard, while still keeping the list view and it's items above visible and scrollable. I'm close to this by setting AdjustResize in my MainActivity.

The problem now is that the grid view beneath the entry gets pushed above the soft keyboard. I want it to be fixed to the bottom, i.e. hidden behind the keyboard. Is there anyway to achieve this, such as align parent bottom like in Android?

I have tried using scrollviews and stacklayout VerticalOptions but these haven't created the desired effect.

Here is my Xaml as it stands:

<ContentPage.Content>
    <StackLayout BackgroundColor="LightGray">
        <Grid VerticalOptions="FillAndExpand">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <ListView x:Name="ListView"
               . . .
            </ListView>
        </Grid>
        <StackLayout Orientation="Horizontal" IsVisible="{Binding EntryShowing}">
            <Entry x:Name="Entry"
                    Text="{Binding EntryText}"
                    TextChanged="TextChanged"
                    HorizontalOptions="FillAndExpand"
                    Placeholder="PlaceHolder" 
                    Keyboard="Numeric"/>
            <Button Text="Button" Command="{Binding Command}"
                    HorizontalOptions="End"/>
        </StackLayout>
        <Grid Margin="5, 5" VerticalOptions="End">
            <Button x:Name="Button"
                    IsVisible="False"
                    Grid.Column="0"
                    VerticalOptions="CenterAndExpand"
                    HorizontalOptions="Start"
                    HeightRequest="30"
                    Text="Button"
                    FontSize="Micro"
                    FontAttributes="Bold"
                    TextColor="White"
                    BackgroundColor="Red"
                    Command="{Binding Command}" />
            <Button x:Name="SubmitButton"
                    Grid.Column="1"
                    VerticalOptions="CenterAndExpand"
                    HorizontalOptions="End"
                    HeightRequest="30"
                    CornerRadius="3"
                    Text="Done"
                    FontSize="9"
                    TextColor="White"
                    BackgroundColor="#5989B5"
                    Command="{Binding FinishCommand}"
                    IsVisible="{Binding IsVisible}" />
        </Grid>
    </StackLayout>
</ContentPage.Content>

How to get the grid.row and grid.column value while clicking the button

$
0
0


<Grid.RowDefinitions>



</Grid.RowDefinitions>
<Grid.ColumnDefinitions>



</Grid.ColumnDefinitions>

    <Button Grid.Row="0" Grid.Column="0" BackgroundColor="White" Clicked="Button_Clicked"/>
    <Button Grid.Row="0" Grid.Column="1" BackgroundColor="White" Clicked="Button_Clicked"/>
    <Button Grid.Row="0" Grid.Column="2" BackgroundColor="White" Clicked="Button_Clicked"/>

    <Button Grid.Row="1" Grid.Column="0" BackgroundColor="White" Clicked="Button_Clicked"/>
    <Button Grid.Row="1" Grid.Column="1" BackgroundColor="White" Clicked="Button_Clicked"/>
    <Button Grid.Row="1" Grid.Column="2" BackgroundColor="White" Clicked="Button_Clicked"/>

    <Button Grid.Row="2" Grid.Column="0" BackgroundColor="White" Clicked="Button_Clicked"/>
    <Button Grid.Row="2" Grid.Column="1" BackgroundColor="White" Clicked="Button_Clicked"/>
    <Button Grid.Row="2" Grid.Column="2" BackgroundColor="White" Clicked="Button_Clicked"/>
</Grid>

While clicking a button i need to fetch the row and column value.Is it possible?

Hi, I am facing Deployment to emulator error in Xamarin Forms

$
0
0

I am trying to build a Xamarin forms Application, It's a blank code, the code builds perfectly without error but it does not get deployed on an emulator.

If I click "Start without Debugging" then the application gets installed on my emulator or else it stays black and after building complete I get just a "Ready" output. It happened all of sudden. Visual Studio version: VS2017 15.9.6

Can anyone help me with this? It started out of nowhere.

I tried to search for mono in "Extensions and Update" to enable it but couldn't find anything installed. If I try to install mono it gives an error "Either it is not compatible or already installed"

Also in my registry, I can't find the SDK path.

I need visual studio to build and display output in emulator.!

Configure the Button's text color (click effect) when a user clicked on it

$
0
0

Hi guys,

I am using two buttons into one of my pages' TitleView and I would like to configure their text color when a user is clicking on them.
I am talking about the effect proving that the event happened correctly.

The color being display by the effect is way too dark and since my buttons (white as text color) are located into my Toolbar (dark blue as background color), it doesn't create a nice result. Any idea to do that ? A renderer maybe ?

I thank you in advance for your time and your response !
Best regards,

Timer multiple call

$
0
0

Hi :)
I'm facing a problem with timer. I tried to make a countdown (from 60s to zero) and everything works fine when I first call the method, but when I call it second time, it goes twice as fast and so on... How to fix it?
method Casomira simply means Countdown
Here is my code:

This didn't work: timer set to null, timer autoreset...
tried to find it everywhere

Android VideoPlayer not setting invisible

$
0
0

Hello, I have been bashing my head with android and its video players for quite a while. After few days on this specific problem I gave up and registered here.

My problem is that I need videoplayer in the top of the screen, and I want it to go fullscreen after button is pressed. Also, I want all this to happen on the same UI stack. Using FormsVideoLibrary I managed to achieve this, sort of.

Now I have this issue on emulator:

Going out of full screen videoplayer does not dissaper (after setting IsVisible= false), instead it freezes, displaying frame on stop, and apears on top of videoplayer that should play.

On Device:
The problem happening on emulator does not occur, instead the first video player is set on top of another, even when it IsVisible = false ( parent view is also IsVisible = false)

Some of the code that is executed after fullscreen button is pressed >

         private void ChangeScape()
                {   
                    if (isitlandscape == false)
                    {
                        isitlandscape = true;
                        MessagingCenter.Send(this, "allowLandScapePortrait");                    
                        videoPlayer.Stop();    // pause() does same
                        CurrentPosition = videoPlayer.Position;
// setting everything invisible                 
                        MainVideoStack.IsVisible = false;
                        videoPlayer.IsEnabled = false;
                        videoPlayer.IsVisible = false;
                        videoPlayer.IsTabStop = false; // trying everything here
                        MainCanvasStack.IsVisible = false;
                        ThirdPageListViewXaml.IsVisible = false;
                        MainStackButtons.IsVisible = false;
                        secondstack.IsVisible = true; // full screen video with its ui elements 

                        VideoPlayerTwoControl(); // runs video

                    }
                    else if(isitlandscape == true)
                    {
                        isitlandscape = false;
                        videoPlayertwo.Stop();
                        CurrentPosition = videoPlayertwo.Position;
//setting elements to false
                        secondstack.IsVisible = false;
                        videoPlayertwo.IsVisible = false;
                        videoPlayertwo.IsEnabled = false;
//turning on elements 
                        MainVideoStack.IsVisible = true;
                        MainCanvasStack.IsVisible = true;
                        ThirdPageListViewXaml.IsVisible = true;
                        MainStackButtons.IsVisible = true;      
                        MessagingCenter.Send(this, "preventLandScape");
                        // TODO should start playing video
                    }
                }

Anyone can give me something? I feel like its some stupid mistake. On the bright side, atleast I can play 2 videos on top of each other, YaY!

System.Xml.Dll assembly only loading on breakpoint

$
0
0

Hello,

I have been migrating all my project from an old version of xamarin with an old version of mono to the latest of both.
Amongst all the other issues I have encountered and found a solution, here is one I am still stuck with.

When I start my application on Debug, some part of a code sends an exception:
var source = new TraceSource(traceName);
source.Listeners.Clear();

The source.Listeners.Clear(); says the following:
System.MissingMethodException: Default constructor not found for type System.Diagnostics.FilterElements

Here comes the funny part: if I put a breakpoint on this line, and hoover the "Listeners" word, I got the error above on a little warning windows. But meanwhile in the logs of the application, the DLL loads himself (at the same moment I hoover the word):
Loaded assembly: /Users/...../System.Xml.dll [External]

And then the application runs smoothly, without errors, and the listeners work.

If I don't put the breakpoint, the application will not run properly.

Any idea on this one?

N.B.: I have migrated the application so it compiles in 64bits, retargeted a bunch of packages, etc. So Maybe I have broken something, but I have no idea what.

How to getdevice token ID from RegisteredForRemoteNotifications

$
0
0

Hey
I need to get the device token id when my IOS application start.
the bellow RegisteredForRemoteNotifications is running in the APPdelegate.cs and i am getting the NSData devicetoken. But how to extract the Device Token ID that i can use to push notification to that device. (like s.token in the second script)

public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
                {
                    string str = deviceToken.Description;
                    FirebasePushNotificationManager.DidRegisterRemoteNotifications(deviceToken);

        //trying here to extract the token id from devicetoken. I need to save it to my database with no result
        //var tokenStringBase64 = deviceToken.GetBase64EncodedString(NSDataBase64EncodingOptions.None);
                   // NSString nstoken = NSString.FromData(deviceToken, NSStringEncoding.UTF8);
                    //String token = nstoken.ToString();
                    //String aa = (String)deviceToken;
                    //var deviceTokenString = deviceToken.ToString().Replace("<", "").Replace(">", "").Replace(" ", "");
                }

If i go to Firebase console and send notification to all IOS application i can found this token ID from **s.token **in the bellow script

    CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) =>
                        {System.Diagnostics.Debug.WriteLine(s.token);};

i spent 4 to 5 hours and i didnt arrive to get it..


Download manager for xamarin.android and xamarin.ios

$
0
0

Hi,

Do we have any Good download manager for xamarin.android and xamarin.ios Which can handle different scenarios like

a. Pause and resume functionality.
b. Parallel Download of the multiple items.
c. Automatically restart the download if the internet connectivity is lost and resumed

I knew this was going to happen.. I broke my application use work in Android now it does not. :(

$
0
0

I was dreading this...

I worked all day today to get this application to run on apple meaning getting the dev account info and getting the application to run via a connected Macintosh computer get a device registered and all the other apple hoops you have to jump through... and now my xamarin application for that worked great in Android will not compile...

I get the following errors now:

Severity Code Description Project Path File Line Source Suppression State
Error ADB0020: The package does not support the CPU architecture of this device.
at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A_work\21\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 337
at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.b__0(Task1 t) in E:\A\_work\21\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753 at System.Threading.Tasks.ContinuationTaskFromResultTask1.InnerInvoke()
at System.Threading.Tasks.Task.Execute() 0 Build

So now I cant get it to run on the Android emulator...

Let me ask you all what is the best practices here...

Should I Just creat two visual studio projects and have one setup for the apple and one set up for the Android...

I guess my only bet now is to pull and old version from source control...

THanks for any advice...sorry so many questions... but this experience with xamarin has been a horror show and I just want it to end.

How create renderer BackgroundImage and BackgroundColor a Layout?

$
0
0

Hi everyone, Good Work!! :)

I want use on every page this View.(this page White part Image and Silver part BackgroundColor)
But i cant find Renderer Codes. Any can share me a sample or code?
or is there a another solution?

Xamarin.iOS & Xamarin.Android Developer Experience

$
0
0

Hi All,

I've been playing with Xamarin.Forms and as a newcomer to the framework / tooling I've not been having a great experience being honest. XAML previewer not really working and randomly crashing, a few builds just not building then next try working, auto complete not working until I restart VS for my own XAML controls etc, all which has lowered my confidence of using Xamarin.

I know I'm not alone reading the forums and so on but also I know a lot of people make great apps with Xamarin and I love C# and the ecosystem so am investigating the possibility of using Xamarin.iOS and Xamarin.Android instead of Xamarin.Forms.

I have a base knowledge of native iOS app dev, Swift, Xcode etc so I can (for example) use Xcode to create a ToDo list type app just fine and am thinking Xamarin.iOS might be a better route for me to start with? Later on I can add an Android UI when I come up to speed with the basics of Android native dev and code share the business logic etc?

I wanted to ask what the experience is like generally for people using Xamarin.iOS and Xamarin.Android nowadays vs Forms? Are things generally better / less buggy do you feel? If I'm reading the wind right people generally have a better time with Xamarin.iOS & Xamarin.Android. Please be gentle if that's not the case lol

Hoping to find a way forward, appreciate any thoughts, cheers all!

Scanning Wifi from PCL project using Dependency Service

$
0
0

Hello!
I need to scan the wifi programatically and return a list of all SSID's I get. I've read about it and concluded I can't make it on iOS in a way I can publish the App on the Apple Store(ref).
So, I decided to at least implement it for Android Users, I'm trying to implement via Dependency Service but I'm doing it wrong, here is what I'm doing:

This is the Wifi.cs class in the Android project:

using AirSenseApp.Services;
using Android.Content;
using Android.Net.Wifi;
using System.Collections.Generic;

[assembly: Xamarin.Forms.Dependency(typeof(AirSenseApp.Droid.Classes.Wifi))]
namespace AirSenseApp.Droid.Classes
{
    public class Wifi:IWifi
    {
        private Context context = null;
        private static WifiManager wifi;
        private WifiReceiver wifiReceiver;
        public static List<string> WiFiNetworks;

        public Wifi(Context ctx)
        {
            this.context = ctx;
        }

        public void GetWifiNetworks()
        {
            WiFiNetworks = new List<string>();

            // Get a handle to the Wifi
            wifi = (WifiManager)context.GetSystemService(Context.WifiService);

            // Start a scan and register the Broadcast receiver to get the list of Wifi Networks
            wifiReceiver = new WifiReceiver();
            context.RegisterReceiver(wifiReceiver, new IntentFilter(WifiManager.ScanResultsAvailableAction));
            wifi.StartScan();
        }

        public class WifiReceiver:BroadcastReceiver
        {
            public override void OnReceive(Context context, Intent intent)
            {
                IList<ScanResult> scanwifinetworks = wifi.ScanResults;
                foreach(ScanResult wifinetwork in scanwifinetworks)
                {
                    WiFiNetworks.Add(wifinetwork.Ssid);
                }
            }
        }
    }
}

This is my Interface that I'm trying to implement on the PCL project:

using System;
using System.Collections.Generic;
using System.Text;

namespace AirSenseApp.Services
{
    public interface IWifi
    {
        void GetWifiNetworks();

    }
}

Is this the correct way to implement it? I tried to put it in my ViewModel this way:

public class CreateDeviceViewModel:INotifyPropertyChanged
{
    private readonly IWifi _wifiService;
    public CreateDeviceViewModel()
    {
        this._wifiService = DependencyService.Get<IWifi>();
    }
    public ScanWifiButtonPressed()
    {
        _wifiService.GetWifiNetworks();
    }
}

But I receive this error:
[0:] System.MissingMethodException: Default constructor not found for type AirSenseApp.Droid.Classes.Wifi

This means I'm not implementing the Wifi.cs in the Android project in the correct way or the problem is in the Interface?

Xamarin forms android splash screen appear when navigation.pushasync and navigation.popasync

$
0
0

style.xml

<? xml version="1.0" encoding="utf-8"? >
< resources >
< style name = "MainTheme" parent="MainTheme.Base" >
< /style >
< item name = "windowNoTitle"> true < /item >
< item name="windowActionBar">false< /item>
< item name = "colorPrimary">#2196F3< /item>
< item name="colorPrimaryDark">#1976D2< /item>
< item name = "colorAccent">#FF4081< /item>
< item name="windowActionModeOverlay">true
< item name = "android:datePickerDialogTheme" > @style / AppCompatDialogStyle </ item >
</ style>
< style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog" >
< item name = "colorAccent" >#FF4081< /item>
< /style>
< style name="MyTheme.Splash" parent="Theme.AppCompat.Light.NoActionBar" >
< item name = "android:windowBackground"> @drawable / Splash_background < / item>
</ style>
</ resources>

and

mainActivity class

[Activity(Label = "xxx", Icon = "@mipmap/icon", Theme = "@style/MyTheme.Splash", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, ScreenOrientation = ScreenOrientation.Portrait, WindowSoftInputMode = SoftInput.AdjustResize)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{

    public FirebaseAnalytics firebaseAnalytics;

    protected override void OnCreate(Bundle bundle)
    {
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;

        base.OnCreate(bundle);
        LoadApplication(new App());
    }

}

help me to resolve the issue

Xamarin forms splash screen visible navigate to another page

$
0
0

splash screen visible when navigate to new page in xamarin.forms android. i want remove or hide the background image


Xamarin Designer replaces constraints to Superview with constraints to Safe Area

$
0
0

We are trying to create a custom header following the steps described here:
https://medium.com/@kahseng.lee123/creating-custom-navigation-bar-tab-bar-for-iphone-x-f03b1e1827d3

Everything works fine and background view snaps to superview leading and trailing ages as expected. It does it correctly in both landscape and portrait mode and on both iPhone X as well as on iPhone 8.

However, if we close the storyboard and open it again, the background view constraints that were set to leading and trailing ages of superview get replaced with constraints to Safe Area. This breaks the design where the background view would not extend all the way to the edges on iPhone X.

We reproduced this behavior with a simple view on both Visual Studio Mac and Microsoft Visual Studio for Windows

Is this a bug or expected behavior? If later, what would be the correct way to extend the background view to the edges of the screen on both iPhone 8 and iPhone X?

CompaNova LLC

Xamarin forms how to remove splash image once loaded

$
0
0

splash screen image appear when navigate one page to another page. i want remove or hide after splash screen loaded.

How to get list of Wifi Networks

$
0
0

I am trying to get a list of Wifi Networks. I am trying to isolate the code into its own class (see below.) The Intent Filter WifiReceiver never seems to be called. Once it is working, since I don't necessarily know when the WiFiNetworks List will be completely populated, is it proper programming, in Android, to set a flag letting me know once the WifiReciever class has completed populating the List? I want to populate a Spinner with the results from this List.

using Android.Content;
using Android.Net.Wifi;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace RingerLocation.Utility
{
    public class Wifi
    {
        private Context context = null;
        private static WifiManager wifi;
        private WifiReceiver wifiReceiver;
        public static List<string> WiFiNetworks;

        public Wifi(Context ctx)
        {
            this.context = ctx;
        }

        public void GetWifiNetworks()
        {
            WiFiNetworks = new List<string>();

            // Get a handle to the Wifi
            wifi = (WifiManager)context.GetSystemService(Context.WifiService);

            // Start a scan and register the Broadcast receiver to get the list of Wifi Networks
            wifiReceiver = new WifiReceiver();
            context.RegisterReceiver(wifiReceiver, new IntentFilter(WifiManager.ScanResultsAvailableAction));
            wifi.StartScan();
        }

        class WifiReceiver : BroadcastReceiver
        {
            public override void OnReceive(Context context, Intent intent)
            {
                IList<ScanResult> scanwifinetworks = wifi.ScanResults;
                foreach(ScanResult wifinetwork in scanwifinetworks)
                {
                    WiFiNetworks.Add(wifinetwork.Ssid);
                }
            }
        }
    }
}

error getting properties from device

$
0
0

MOTO G5 PLUS Android 8.1.0
Windows 10 1803
Visual Studio Comminity 2017 V 15.9.4

[I:]: Got new device list from adb with 0 devices
[D:]: TrackDeviceTask got: ZY224KW8ZP connecting
[I:]: Got new device list from adb with 1 devices
[D:]: TrackDeviceTask got: ZY224KW8ZP device
[I:]: Got new device list from adb with 1 devices
[D:RunShellCommand]: ZY224KW8ZP getprop
[E:]: Error getting properties from device 'ZY224KW8ZP'
Mono.AndroidTools.AdbException: Multi-line processing failed for getprops: ''
at Mono.AndroidTools.Internal.AdbOutputParsing.ParseGetprop(String properties) in E:\A_work\293\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 108
at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass72_0.b__0(Task1 t) in E:\A\_work\293\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 507 at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Mono.AndroidTools.AndroidDevice.d__48.MoveNext() in E:\A_work\293\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 284
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Mono.AndroidTools.DevicePropertiesTracker.d__9.MoveNext() in E:\A_work\293\s\External\androidtools\Mono.AndroidTools\AndroidDeviceManager.cs:line 544

NavigationPage in Xaml

$
0
0

Sorry for such a simple question. What is the structure for the NavigationPage in xaml?

Among others, this is what I have tried.

<?xml version="1.0" encoding="UTF-8" ?>
<NavigationPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="My.Shared.Page">
    <NavigationPage.Content>
            <ScrollView>
                <StackLayout x:Name="layout" Orientation="Vertical" VerticalOptions="Start" HorizontalOptions="Center">  
                <ActivityIndicator x:Name="activity"></ActivityIndicator>                                                   
                </StackLayout>  
            </ScrollView>    
    </NavigationPage.Content>
</NavigationPage>


<?xml version="1.0" encoding="UTF-8" ?>
<NavigationPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="My.Shared.Page">
    <NavigationPage>
        <ContentPage>
            <ScrollView>
                <StackLayout x:Name="layout" Orientation="Vertical" VerticalOptions="Start" HorizontalOptions="Center">  
                <ActivityIndicator x:Name="activity"></ActivityIndicator>                                                   
                </StackLayout>  
            </ScrollView>    
        </ContentPage>    
    </NavigationPage>
</NavigationPage>
Viewing all 204402 articles
Browse latest View live


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