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

MissingMethodException: 'Android.Support.V4.Widget.DrawerLayout.AddDrawerListener' not found

$
0
0

I have followed everything from the following link:
https://developer.xamarin.com/guides/xamarin-forms/user-interface/navigation/master-detail-page/
The code I wrote can be found here: http://github.com/foyzulkarim/XamarinFormsDrawer

I successfully deployed the same project in my Windows 10 Local machine using UWP project, but whenever I want to deploy in Emulator, or in my device, it is throwing the following exception.

System.MissingMethodException: Method 'Android.Support.V4.Widget.DrawerLayout.AddDrawerListener' not found.
09-17 17:16:33.636 D/Mono    (10472): DllImport attempting to load: '/system/lib/liblog.so'.
09-17 17:16:33.637 D/Mono    (10472): DllImport loaded library '/system/lib/liblog.so'.
09-17 17:16:33.637 D/Mono    (10472): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
09-17 17:16:33.637 D/Mono    (10472): Searching for '__android_log_print'.
09-17 17:16:33.637 D/Mono    (10472): Probing '__android_log_print'.
09-17 17:16:33.637 D/Mono    (10472): Found as '__android_log_print'.
09-17 17:16:33.645 I/MonoDroid(10472): UNHANDLED EXCEPTION:
09-17 17:16:33.658 I/MonoDroid(10472): System.MissingMethodException: Method 'Android.Support.V4.Widget.DrawerLayout.AddDrawerListener' not found.
09-17 17:16:33.658 I/MonoDroid(10472):   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x0001f] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Platform.cs:282 
09-17 17:16:33.658 I/MonoDroid(10472):   at Xamarin.Forms.Platform.Android.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement view) [0x00000] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\RendererFactory.cs:10 
09-17 17:16:33.658 I/MonoDroid(10472):   at Xamarin.Forms.Platform.Android.AppCompat.Platform.AddChild (Xamarin.Forms.Page page, System.Boolean layout) [0x00015] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:248 
09-17 17:16:33.658 I/MonoDroid(10472):   at Xamarin.Forms.Platform.Android.AppCompat.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x00089] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:237 
09-17 17:16:33.658 I/MonoDroid(10472):   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.InternalSetPage (Xamarin.Forms.Page page) [0x0009b] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:336 
09-17 17:16:33.658 I/MonoDroid(10472):   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.SetMainPage () [0x00000] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:410 
09-17 17:16:33.659 I/MonoDroid(10472):   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.LoadApplication (Xamarin.Forms.Application application) [0x00158] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:123 
09-17 17:16:33.659 I/MonoDroid(10472):   at App1.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00018] in C:\Users\foyzu\Source\Github\XamarinForms\XamarinFormsDrawer\App1\App1\App1.Droid\MainActivity.cs:23 
09-17 17:16:33.659 I/MonoDroid(10472):   at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in <71c3e52f1b484794bca1cdfb1b8b1fdb>:0 
09-17 17:16:33.659 I/MonoDroid(10472):   at (wrapper dynamic-method) System.Object:1a87dfa6-a154-49b0-925d-8ddad74d97cf (intptr,intptr,intptr)
09-17 17:16:33.677 W/art     (10472): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
09-17 17:16:33.681 D/Mono    (10472): DllImport searching in: '__Internal' ('(null)').
09-17 17:16:33.681 D/Mono    (10472): Searching for 'java_interop_jnienv_throw'.
09-17 17:16:33.681 D/Mono    (10472): Probing 'java_interop_jnienv_throw'.
09-17 17:16:33.681 D/Mono    (10472): Found as 'java_interop_jnienv_throw'.
An unhandled exception occured.

09-17 17:16:34.399 E/mono    (10472): 
09-17 17:16:34.399 E/mono    (10472): Unhandled Exception:
09-17 17:16:34.399 E/mono    (10472): System.MissingMethodException: Method 'Android.Support.V4.Widget.DrawerLayout.AddDrawerListener' not found.
09-17 17:16:34.399 E/mono-rt (10472): [ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method 'Android.Support.V4.Widget.DrawerLayout.AddDrawerListener' not found.
referenceTable GDEF length=814 1
referenceTable GSUB length=11364 1
referenceTable GPOS length=47302 1

Findbyname returns null in xamarin.winPhone

$
0
0

I am currently on Xamarin PCL . when initializing the controls of xaml( using Findbyname<>, everything is returned as null.
The same works well on android and iOS.

Open local files in xamarin.forms

$
0
0

I need to open local file, here is my solution in Android project.

Intent intent = new Intent(Intent.ActionView);
var file = new File("content://" + path);
var uri = FileProvider.GetUriForFile(Application.Context, BuildConfig.ApplicationId + ".provider", file);
intent.SetDataAndType(uri, GetMimeType(path));
intent.SetFlags(ActivityFlags.ClearWhenTaskReset | ActivityFlags.NewTask);
intent.AddFlags(ActivityFlags.GrantReadUriPermission);

But file provider don't work and app crashes without any errors. I need to add provider to my androidmanifest.xml

<provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="${applicationId}.provider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths"/>
</provider>

But how can I add this in xamarin.forms, I don't have android manifest file.

MainPage.xaml.cs sharing with MainActivity.cs

$
0
0

I noticed I can only access objects (labels etc...) from MainPage.xaml.cs.
Certain things, like a NuGet Bluetooth pacakage i have (Plugin.BLE) Can only be referenced in MainActivity.
So, what I need, is either a way to use my Plugin.BLE in MainPage.xaml.cs...
Or, to be able to access my label etc, from MainActivity.
Any help?

Toolbar item text change dynamically

$
0
0

Toolbar item text change dynamically in xamarin forms, is it possible? I am using MVVM pattern to update the text,but the text was not updating......

Thanks in advance...

Troubleshooting "too many open files" exception in iOS version of xamarin.forms app

$
0
0

We develop apps for iOS and Android using xamarin.forms. In appcenter, it turns out that one of our apps sporadically crashes in iOS with an error: "System.IO.IOException: Too many open files".

We've been googling on what causes this issue. We checked all our code, and we made sure (as far as we can find) that all filestreams are properly closed and disposed after usage. We also found that the garbage collector of iOS can be too late in collecting the streams, so we added a manual GC.Collect() call in the methods using filestreams.

However, the issue still seems to appear. Is there a way we can monitor if any file handles are not being closed, so we can find out why this error still occurs?

Some info that might be relevant for troubleshooting suggestions:

  • We're using Xamarin.Forms
  • We're using Visual studio 2017 on Windows PC
  • We have a mac connection in Visual studio to be able to build and debug the iOS version of our app

The full stacktrace of the crash:

System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) <0x105032c20 + 0x005c8> in :0 System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean isAsync, System.Boolean anonymous) <0x105032b70 + 0x0008f> in :0 System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.IsolatedStorage.IsolatedStorageFile isf) <0x10503beb0 + 0x00057> in :0 System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.IsolatedStorage.IsolatedStorageFile isf) <0x10503c000 + 0x00067> in :0 IsolatedStorageFile.OpenFile (System.String path, System.IO.FileMode mode) Deserializer+<>c.b__1_0 () Task1[TResult].InnerInvoke ()
Task.Execute ()
ExceptionDispatchInfo.Throw ()
TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task)
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task)
TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task)
ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () Application+d__69.MoveNext ()

XML without root element

$
0
0

I want to consume web api and print the output on xamarin forms. web api returns output in xml format. however it does not have a root element.
XML format is something like this:
Is this a valid format?
A
a /a
b /b
/A

A
a /a
b /b
/A

XDocument.parse gives null.
Exception message is Data at the root level is invalid.

Is it possible to add root element to web api which is deployed on server?
how should i convert xml to json?

Excuse the formatting. Text disappears if i use<> tags

I'm getting build error in my project

$
0
0

This is my project https://github.com/moljac/Xamarin.Auth.Samples.NugetReferences and This is the error I"m getting

Severity Code Description Project File Line Suppression State
Error The project file "............\source\XamarinForms\Xamarin.Auth.Forms\Xamarin.Auth.Forms.csproj" was not found. ComicBook
Severity Code Description Project File Line Suppression State
Error The project file "............\source\Xamarin.Auth.Portable\Xamarin.Auth.Portable.csproj" was not found. ComicBook

Please help me. Ur help will be appreciated.


Best way to pass info back to previous page

$
0
0

Hello there!

I'm solving troubles by my own, but sometiems I need some advices.
I have to select a list of items, so I create a ListView page, got its ViewModel with a list, and when I got all done, you tap "Ok"and I delete items not selected from the list. Now I need to pass this list to the parent page to work with it.
I found some solutions, but I wonder what is the best:

  • First option is: parent page has the instance of the child's ViewModel because it was the one who create it. So my first option was to use OnAppearing to check if the child ViewModel exists and it has any element remaining in it's list, to grab them and do whatever it needs.
  • My second though was to pass the parent ViewModel to the child as a parameter, and when the child work is done, call a parent ViewModel command with the selected item list to work with, and when it finish, use Navigation.PopAsync().
  • Lastly, I read some more, and I found Navigation.GoBackAsync. It looks good because it can call the parent ViewModel command when it's returning only from a child, but I'm not sure if it works the same way as PopAsync method but adding an event and parameters.

What's the best option to get the code as simple as possible (keep in mind that I'm a noob in Xamarin and I'm learning bit by bit ^^U).
Thank you!!

Using xamarin forms mvvm how to set tab bar at bottom of the page in android like as ios?

$
0
0

I working on xamarin forms using MVVM. I want to set tabs on bottom in android like as tabs on iOS. If any one have idea about that let me know.

Thanks in advance :)

how to integrated the complex css website in xamarin.form?

$
0
0

Hi, we had one web application build with complex CSS & business logic layer in Asp.net. Now as per requirement we want to build mobile application for same website using existing CSS & class file. The site is already mobile responsive, but we want to create hybrid mobile application with native look and feel. Hence we are looking for solution in xamarin cross platform.

Custon Render for ToolbarItens

$
0
0

Hello Every body
I need to implement a rounded icon in nav bar like whatsapp photo profile
Can help me please...
How can i do a custon render for toolbaritens round icon

Twoway binding for object properties not working

$
0
0

This is my Xaml

<Image Grid.Column="0" Grid.Row="0" Source="contactIcon.png" />
<Entry Grid.Column="1" Grid.Row="0"  Text="{Binding SelectedContact.FNAME,Mode=TwoWay}" Placeholder="First Name" />
<Entry Grid.Column="1" Grid.Row="1"  Text="{Binding SelectedContact.LNAME,Mode=TwoWay}" Placeholder="Last Name"/>
<Image Grid.Column="0" Grid.Row="2" Source="calIcon.png" />
<Entry Grid.Column="1" Grid.Row="2" Text="{Binding SelectedContact.PHONE,Mode=TwoWay}" Placeholder="Mobile" Keyboard="Telephone"/>
<Image Grid.Column="0" Grid.Row="3" Source="emailIcon.png" />
<Entry Grid.Column="1" Grid.Row="3" Text="{Binding SelectedContact.EMAIL,Mode=TwoWay}" Placeholder="Email" Keyboard="Email"/>
<Entry Grid.Column="1" Grid.Row="4" Text="{Binding SelectedContact.BALANCE,Mode=TwoWay}" Placeholder="Email" Keyboard="Email"/>

Contact model

    public int ID { get; set; }
    public string FNAME { get; set; }
    public string LNAME { get; set; }
    public string PHONE { get; set; }
    public string EMAIL { get; set; }
    public Double BALANCE { get; set; }

ContactViewModel

        private Contact _selectedContact;
        public Contact SelectedContact{get { return _selectedContact; }set{ 
        _selectedContact = value; OnPropertyChanged(); } }

OneWay binding is working but i want twoway binding. If i change the text or modify the text in the firstname entry then it should change the FNAME property of SelectedContact.

How would I make a custom round label renderer auto size to its width of text?

$
0
0

How would I make a custom rounded label renderer resize based on the width of the label inside it? I always want a little space to the left and right of the text.

Implementation of Google Sign-In sdk in xamarin.forms

$
0
0

Hi I am trying to create Google Sign In using the Google Sign In SDK as Google has updated its security restrictions for OAuth flow. They are not going to allow native web-views to initiate OAuth flows. I want to use the Google Sign In Sdk in xamarin forms for both android and ios. If any one has already implemented it then please share the information or code for it.


Title of the content page is not displayed

$
0
0

I have updated to lates version of Xamarin.Forms and title defined in Content page is not displayed in Android. The content page is added correctly:

MainPage = new NavigationPage(new Jobs());

Title is populated by IMarkupExtension that pulls the value from a resource file. At first I thought this might not be working but a quick debugging session proved me wrong. I have also tried to put static text in this property but again, it is not displayed.

Has anything changed in the new version that would break my code?

changing Grid.IsVisible to true: child views remain invisible

$
0
0

I have a GridLayout with some child views in it, and initially the grid is invisible (and collapsed), because I set "IsVisible" to false.
Then I have a button to toggle the visibilty of the grid, and when I toggle it for the first time, ie. set IsVisible=true, the grid is not collapsed any more, but all children in it are not visible, there is just a white background. But when I toggle it again (IsVisible=false) and then again (the second time) to IsVisible=true, all child views are visible. I also tried "grid.ForceLayout()" after setting IsVisible to true, but it has no effect.

Any solution to that ?

Problem with using Grid.IsVisible

$
0
0

Hi there
It turned out the Grid.IsVisible (iOS part) works only one way: when IsVisible=true, it appears.
If set IsVisible=false, it hides but holds the place of the same size it had. Just blank ugly void.
Nevertheless, the Xamarin doc reads:

Setting IsVisible to false will remove the element from the visual tree. The element will no longer take up space in layouts or be eligle to receive any kind of input event

Apparently, it is a bug.
Any clue how to work around?
Thanks.

ListView databinding just won't work

$
0
0

I have the following page in XAML:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="ht_tp://xamarin.com/schemas/2014/forms"
xmlns:x="ht_tp://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:DietAndFitness.ViewModels"
x:Class="DietAndFitness.Views.FoodDatabasePage">
<ContentPage.Content>
<StackLayout>
<ListView ItemsSource="{Binding FoodItems}" RowHeight="120">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ContentView Padding="5">
<Frame OutlineColor="Accent" Padding="10">
<StackLayout>
<Grid HorizontalOptions="Center">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label Text="{Binding Name}" FontSize="22" VerticalOptions="CenterAndExpand" HorizontalOptions="Center" Grid.Row="0" Grid.Column="0"/>
<Label Text="{Binding Calories}" FontSize="22" VerticalOptions="CenterAndExpand" HorizontalOptions="Center" Grid.Row="0" Grid.Column="1"/>
</Grid>
<Grid HorizontalOptions="Center">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label Text="Carbohydrates" Grid.Row="1" Grid.Column="0" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" FontSize="16"/>
<Label Text="Proteins" Grid.Row="1" Grid.Column="1" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" FontSize="16"/>
<Label Text="Fats" Grid.Row="1" Grid.Column="2" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" FontSize="16"/>
<Label Text="{Binding Carbohydrates}" Grid.Row="2" Grid.Column="0" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" FontSize="16"/>
<Label Text="{Binding Proteins}" Grid.Row="2" Grid.Column="1" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" FontSize="16"/>
<Label Text="{Binding Fats}" Grid.Row="2" Grid.Column="2" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" FontSize="16"/>
</Grid>
</StackLayout>
</Frame>
</ContentView>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Grid HorizontalOptions="Center">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button x:Name="AddFoodItemButton" BackgroundColor="LightGray" HorizontalOptions="CenterAndExpand" Text="Add" Grid.Row="0" Grid.Column="0" Clicked="AddFoodItemButton_Clicked" />
<Button x:Name="EditFoodItemButton" BackgroundColor="LightGray" HorizontalOptions="CenterAndExpand" Text="Edit" Grid.Row="0" Grid.Column="1" />
<Button x:Name="DeleteFoodItemButton" BackgroundColor="LightGray" HorizontalOptions="CenterAndExpand" Text="Delete" Grid.Row="0" Grid.Column="2" />
</Grid>
</StackLayout>
</ContentPage.Content>

And this is the code behind:

 public FoodItemsViewModel FoodDatabase { get; set; }
      public FoodDatabasePage ()
      {

        InitializeComponent ();
        FoodDatabase = new FoodItemsViewModel(SQLiteConnection.Database);
        BindingContext = FoodDatabase;

    }

    protected override void OnAppearing()
    {
        FoodDatabase.LoadList();
    }

    public void AddFoodItemButton_Clicked(object sender, EventArgs e)
    {
        FoodDatabase.Add();
    }

But my ListView just comes up empty. The only way I've managed to get the list populated is if I do

<ListView ItemsSource="{x:Static local:FoodItemsViewModel.FoodItems" RowHeight="120">
And make the ObservableCollection in my VM static. This is my VM:

     public class FoodItemsViewModel 
      {
       private SQLiteAsyncConnection database;


    public ObservableCollection<GlobalFoodItem> FoodItems { get; set; }


    public FoodItemsViewModel(SQLiteAsyncConnection _database)
    {
        database = _database;

    }

    public async void LoadList()
    {

            FoodItems = new ObservableCollection<GlobalFoodItem>(await database.Table<GlobalFoodItem>().ToListAsync());

    }

    public void Add()
    {
        FoodItems.Add(new GlobalFoodItem("Item"));

    }

}

Even if I make my ObservableCollection static the list still doesn't actually load until I reload the page by navigating to another one.

Furthermore attempting to implement INotifyPropertyChanged in my VM results in StackOverflow exception at the ObservableCollection getter (I already implemented INotifiyPropertyChanged in the GlobalFoodItem class, maybe it has something to do with it?).

Also, here is the github for the project htt_ps://github.com/TJorj/DietAndFitness

I have no idea what's going on anymore. How can I get this thing working properly?

File upload, is this possible?

$
0
0

I have an application that is coming along very nicely. However, looking online one of my app requirements requires the ability to take a photo/small file (.doc,.csv,.pdf), nothing huge.

And upload it to our system. I can do this via a web api 2.0 call or something else.

How can I achieve this in an elegant way?

Thanks in advance!

Viewing all 58056 articles
Browse latest View live


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