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

android build error

$
0
0

My project used to build, then I added the azure mobile services client package. Now I get:

Severity Code Description Project File Line Suppression State
Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'System.Net.Http.Primitives.dll'
at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection

1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection
1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute() JobReporter.Droid

The PopModalAsync method pops all page instances

$
0
0

When I used PopModalAsync method to pop up the last page instance, but it pop up all page instances. I don't know why, and I will be grateful to those who can give me a hand.

Caching REST on Xamarin Forms Ideas

$
0
0

Hi All,

This has come up a lot, and there has been some healthy debate on it. But i'm looking for some up to date ideas.

I have a REST API which returns JSON, there is a couple of different interfaces i'm using on the API.

What I am looking for is a good way to cache the data for quick access and also offline access.

A lot of people look at using a mini SQL-lite database on the device itself, but for me the difficulty here is that I need to write SQL queries to read & write the data and considering the JSON is changing (I manage the web interface as well), there is a lot of duplication of work.

The other idea I had was just storing the JSON raw as files to the local filesystem, which means I could just read these and deserialize these the exact same way that I am calling the REST method. The problem with this method is what appears to be how insanely difficult it is to read & write files locally using a PCL project (with no access to System.File.IO).

Is anyone aware of anything that makes this task simple? Or ideas?

How to use multiple grids in a singe Content Page

$
0
0

Hi,

I would like to know if it is possible to use multiple grids in a single page for laying out various controls. That will give me easy control over the number of columns in each grid.

For example the header has 4 columns but the body needs only 2 columns. So how can I place the 2 grids one after the other.

Thanks,

Rajesh.

Newtonsoft json deserialization not working as expected

$
0
0

Hello! For some reason the code below is not working in my Xamarin Forms project:

dynamic json = JsonConvert.DeserializeObject("{\"Name\":\"Steve\"}");
string name = json.Name;

When I execute the code it crashes and says that 'Name' is not defined. What is strange is that when I run that code in a fresh Console Application project, it executes as expected and the 'Name' member is defined. So why would it not work in my Xamarin Forms project? Both projects are using the same version of Newtonsoft's json package v8.0.3. Also my Xamarin Forms version is the latest v2.2.0.31.

Maybe I'm just being stupid and doing something wrong haha but the solution isn't obvious to me at this time. :-)

Thanks!

Code breaks after calling GetAsync method while trying to get data from Rest Service.

$
0
0

Hi There,

I have to get data from a Rest Sertvice in my Android application. I have my logic in PCL. But getting strange errors. Code breaks on reaching GetAsync() method. This is what I am trying:

public async Task GetVehicleDataAsync(string id)
{
restUrl = "https:///getVehicleInfo?vehicleId={0}";

        var url = new Uri(string.Format(restUrl, id));
        using (var client= new HttpClient())
        {
            try
            {
                var response = await client.GetAsync(url).ConfigureAwait(false); //Code breaks here

                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsStringAsync();
                    vehicle = JsonConvert.DeserializeObject<VehicleModel>(content);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"ERROR {0}", ex.Message);
            }
            return vehicle;
        }
    }

Can you please let me know where am I going wrong.?

Error inflating class com.android.internal.widget.ActionBarView

$
0
0

Hello,

I have created an app in Xamarin forms and tested it on several devices successfully.
Unfortunately, the app is not running on the Galaxy Note devices on Google Cloud Test Lab.

  • Galaxy Note3 (hlte)
  • Galaxy Note2 (t03g)
    The tests on the other devices are executed successfully.

The following exception was thrown on both devices:
Probleem: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gkv.app/md500e7bf8c622a4391271531669e99fc72.MainActivity}: android.view.InflateException: Binary XML file line #37: Error inflating class com.android.internal.widget.ActionBarView

Details of the exception:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gkv.app/md500e7bf8c622a4391271531669e99fc72.MainActivity}: android.view.InflateException: Binary XML file line #37: Error inflating class com.android.internal.widget.ActionBarView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class com.android.internal.widget.ActionBarView
at android.view.LayoutInflater.createView(LayoutInflater.java:626)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3296)
at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3359)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:381)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:375)
at android.app.Activity.setContentView(Activity.java:2051)
at md500e7bf8c622a4391271531669e99fc72.MainActivity.n_onCreate(Native Method)
at md500e7bf8c622a4391271531669e99fc72.MainActivity.onCreate(MainActivity.java:28)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:600)
... 27 more
Caused by: android.view.InflateException: Binary XML file line #35: Error inflating class android.widget.TextView
at android.view.LayoutInflater.createView(LayoutInflater.java:626)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at com.android.internal.widget.ActionBarView.initTitle(ActionBarView.java:1200)
at com.android.internal.widget.ActionBarView.setDisplayOptions(ActionBarView.java:982)
at com.android.internal.widget.ActionBarView.(ActionBarView.java:398)
... 30 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:600)
... 40 more
Caused by: java.lang.UnsupportedOperationException: Can't convert to color: type=0x2
at android.content.res.TypedArray.getColor(TypedArray.java:327)
at android.widget.TextView.(TextView.java:1003)
at android.widget.TextView.(TextView.java:908)
... 43 more

I have tried to find a solution on Google, but without success.
This is the code in my MainActivity.cs:


using Android.App;
using Android.Content.PM;
using Android.OS;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

namespace GKV.Droid
{
[Activity(Theme = "@android:style/Theme.Material", Label = "GKV", MainLauncher = true, Icon = "@drawable/splash", ScreenOrientation = ScreenOrientation.Portrait, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)
]
public class MainActivity : FormsApplicationActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);

        Forms.Init(this, bundle);

        LoadApplication(new App());
    }
}

}

Anybody with some ideas how to fix this problem?

Thanks in advance!
Cheers.

Cost effective Cloud sync service for very small data amounts

$
0
0

Hi,

I would like to provide my App users the possibility to have have the same data on each of their devices. There are some charateristics that could be used to optimize the syncing:

  1. Every user will only store about 1MB within 10 years of usage.
  2. Every day on average only 10 syncs per user with not more that 1kb of data will happen.
  3. I don't need a database, pure json files should be sufficient
  4. No user should be able to access the data of other user. So some kind of user credentials must be easily created/validated. Encyrpting the stored files with a user provided key would also be a solution. But then a unique filenaming convention must be realized that is easily to input on each device e.g. based on email adress. But then at least an email validation would be neccessary to have a unique file naming based on emailadress of user.
  5. I have no experience with server side programming so either a commercial service or a opensource solution that I can install on my own server.
  6. This is for a 0,99€ App so it must be cheap/user. The maximum I would say is to get additional InApp sells of 0.99€/Year for syncing option.
  7. Crossplatform for Android, IOs and UWP.

Any Idea is very appreciated.

Thomas


How to create progress bar in xamarian.forms ?

$
0
0
 On Button click event i need progress bar then next activity will be start, so how can i set the progress bar can any one help me....#Thanks.

Custom renderer for ScrollView on Android.

$
0
0

Want to add simple paging to scrollview. On iOS is was easy added customer renderer like this

[assembly:ExportRenderer (typeof(ScrollView), typeof(JustEat.Ordertracker.Touch.Renderers.ExtendedScrollViewRenderer))]
namespace JustEat.Ordertracker.Touch.Renderers
{
public class ExtendedScrollViewRenderer : ScrollViewRenderer
{
protected override void OnElementChanged (VisualElementChangedEventArgs e)
{
base.OnElementChanged (e);
UIScrollView iosScrollView = (UIScrollView)NativeView;
iosScrollView.PagingEnabled = true;
iosScrollView.ShowsHorizontalScrollIndicator = false;
}
}
}

So doesn't like like android has paging flag so was going to implement wih touch events or similar, but can get any events to trigger. SO have tried hooking up events and overtiding

[assembly:ExportRenderer (typeof(ScrollView), typeof(JustEat.Ordertracker.Touch.Renderers.ExtendedScrollViewRenderer))]
namespace JustEat.Ordertracker.Touch.Renderers
{
public class ExtendedScrollViewRenderer : ScrollViewRenderer
{
protected override void OnElementChanged (VisualElementChangedEventArgs e)
{
base.OnElementChanged (e);
global::Android.Widget.ScrollView droidScrollView = (global::Android.Widget.ScrollView)this;

        droidScrollView.HorizontalScrollBarEnabled = false;

        droidScrollView.Drag += delegate
        {
            Console.WriteLine("Drag");
        };
    }

    public override bool OnTouchEvent(global::Android.Views.MotionEvent ev)
    {
        Console.WriteLine("OnTouchEvent");
        return base.OnTouchEvent(ev);
    }
}

}

The OnElementChanged definitely gets called as i hit a breakpoint, but the events do nothing, neither does setting HorizontalScrollBarEnabled to false, or even setting .Enabled to false. Its like I have access to a differnt object ?

any ideas ?

thanks

Open links that start with "http" in a new browser

$
0
0

I have a html page I'm opening in a webview that contains two links:

<p><a href="/m/21df2d07-b8ae-4baa-9b16-e94d7f838700/CustomContent/Index">Local link</a></p>
<div>&nbsp;</div>
<p><a href="http://mysite.mycompany.net/m/f9230b5d-cc5f-4461-8835-4e2aeec57968/CustomContent/Index" >External link</a></p>

on the Android side I handle this in a CustomWebViewClient:

    public override bool ShouldOverrideUrlLoading(WebView view, string url)
    {
        if (url.StartsWith("http"))
        {
            Device.OpenUri(new Uri(url));
            return true;
        }

on the iOS side I attempted to do something similar in the Portable's CustomWebView:

    public CustomWebView()
    {
        Navigating += OnShouldLoad;
    }

    private void OnShouldLoad(object sender, WebNavigatingEventArgs e)
    {
        if (e.Url.StartsWith("http"))
        {
            Device.OpenUri(new Uri(e.Url));
            e.Cancel = true;
            return;
        }

but e.Url always starts with "http", so that didn't work. Then I attempted to make a CustomWebViewDelegate in the iOS project ..

    public override bool ShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
    {
        if (request.Url.Path != null && request.Url.Path.StartsWith("http"))
        {
            Device.OpenUri(request.Url);
            return false;
        }

but request.Url always contains the full address, starting with http, and request.Url.Path never contains the http, it is removed if it was on the link.

In iOS, how do I determine if the link the user clicked on starts with "http"?

how to create an ActivityIndicator that blocks all controls in the page

ListView does not recognize swipes for changing tabs

$
0
0

Hi everyone,

I have problem with listViews in windows phone and tabbed navigation. I have set up three tabs and the first tab contains a listView. When I try to swipe left or right on the first view, the tabs are not changing. However this works perfectly fine on the other two that do not contain listviews.

There is an exception in the first case and the swipes work when I do the swipe outside of the listView area, on the very edge of the screen or on the actual header.

I'd like to be able to swipe between tabs no matter where I do the swipe motion.

How to make a custom design ToolbarItem?

$
0
0

I need a toolbar item that shows the number of messages the user currently has. However, I can't find a way to make a custom design of the ToolbarItem, so it would not be a simple icon, but a combination of image and text displayed as I want it.

Does anyone know how to do this?

Reverse Grid for RightToLeft Languages

$
0
0

A certain page of my app is laid out in a Grid. I would like to reverse the Grid horizontally to display properly in RTL languages. Anyone tackled this before?


Xamarin.Forms Custom Picker with Image

tableview - viewcell - entry randomly seems to be isenabled=false

$
0
0

I have a xamarin forms tableview that has a number of viewcells. Random entry controls in that tableview go into 'IsEnabled = false' or it appears as such anyway, they become greyed out and not usable just like IsEnabled = false.

It always seems to be entry controls, and each time I load the page it might be a different set of control afflicted by this curse. It happened a while ago, and I forgot about it (I recreated the page and changed the order of some cells and thought that might have fixed it). However I have gone back to testing on a different physical device, a tablet, and it is rampant.

Here is the xaml. There is a lot more I could explain about the context but I don't want to cloud the issue.

In this case, the 'Site:' is working just fine and the 'Rig:' is disabled. Other times both are disabled, other times both work.

<ViewCell>
       <StackLayout Orientation="Horizontal" Padding="10,10,0,0" HeightRequest="60">
         <Label Text="Site :"
                        WidthRequest="75"
                        Style="{StaticResource Label_Default-Medium-Default}"
                        VerticalOptions="Center"/>
         <Entry Placeholder=""
                        x:Name="Site"
                        Text="{Binding Site}"
                        Keyboard="Text"
                        WidthRequest="200"/>
       </StackLayout>
      </ViewCell>
       <ViewCell>
       <StackLayout Orientation="Horizontal" Padding="10,10,0,0" HeightRequest="60">
         <Label Text="Rig :"
                        WidthRequest="75"
                        Style="{StaticResource Label_Default-Medium-Default}"
                        VerticalOptions="Center"/>
         <Entry Placeholder=""
                        x:Name="Rig"
                        Text="{Binding Rig}"
                        Keyboard="Text"
                        WidthRequest="200"/>
       </StackLayout>
      </ViewCell>

Get Image Stream from Xamarin Forms Image

$
0
0

Hello all,
I used the XLabs Camera to select an image gallery in my application.
After selecting the image and the same load a preview in the Image object from Xaml, I wonder how to get that image , in my cs code, and turn it into Base64 to send to my WebAPI.

<Button Text="Imagem 1" Command="{Binding SelectPictureCommandOne}" HorizontalOptions="Center" />
<Image x:Name="imgOne" Source="{Binding ImageSourceOne, Mode=TwoWay}" VerticalOptions="CenterAndExpand" WidthRequest="60" HeightRequest="60" HorizontalOptions="Center" />

Can anyone give me a hint?

Thank's,

Rogerio

How to create dynamic controls

$
0
0

Hi,

I want to create a dynamic controls in Xamarin Forms and these dynamic control informations will get from database. i also need to set maxlength, validations, font from database table.

How to access a folder via code that is added to the Xamarin Forms project.

$
0
0

I am writing a XamarinForm App. I have a folder inside each project (ios and Android) that has some data. I want to be able to get to the path of the folder added to the project. I need to access the entire folder and not just one file from it. So I can't really set it as Embedded Resource. Any ideas? I couldn't find a straightforward way of accessing it that is common to all platforms. For iOS I resorted to following, but have no success on Xamarin Android Yet. Any help or pointers are appreciated. Thanks.

if IOS
var strFolderPath = NSBundle.MainBundle.BundlePath;
var compactCache =Path.Combine(strFolderPath, "NorthAmericaCacheV1/Layers");

endif

if ANDROID

//Can't figure out what to do :-(

endif

Viewing all 58056 articles
Browse latest View live


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