I am having an issue while using observable collection in XAML. I have created tabs on my Xamarin.Forms application using observable collection in XAML and for accessing observable collection in XAML I have included this namespace
xmlns:col="clr-namespace:System.Collections.ObjectModel;assembly=System.ObjectModel"
when I am writing System.ObjectModel in assembly it is working fine in iOS and UWP but crashing on Android. If I am writing netstandard assembly instead of System.ObjectModel then it is working fine in Android but crashing in iOS and UWP.
I have tried installing System.ObjectModel package in my project but it didn't work.
My XAML looks something like this
<ResourceDictionary>
<!-- Default list -->
<xcoll:ObservableCollection x:Key="NewTabs" x:TypeArguments="model:ISequenceItem">
<test:FirstPage Order="1" Text="Page 1" />
<test:SecondPage Order="2" Text="Page2" />
<test:ThirdPage Order="3" Text="Page3" />
</xcoll:ObservableCollection>
</ResourceDictionary>
<test:Tabs
ItemSource="{Binding Path=NewTabs}"
SelectedItem="{Binding Path=SelectedTab}">
Related
When i upload a relese to Google Play Console, after internal testing y have a warning (Accessibility => Content labeling) associated to this component.
<ImageButton .../>
Here the recomendation is use android:contentDescription
Then i add xmlns:android="http://schemas.android.com/apk/res/android"
and:
<ImageButton android:contentDescription="bla bla" .../>
But i get an error: The property contentDescription was not found in type ImageButton.
I try to use xct:SemanticEffect.Description and i have not compiler error but in Google Play Console i still see the warning.
More Information:
Full component code:
<ImageButton BackgroundColor="Transparent" Margin="5" xct:SemanticEffect.Description="abrir menú" Clicked="OnBackButtonClicked" >
<ImageButton.Source>
<FontImageSource FontFamily="FAL" Glyph="" Color="{StaticResource Gray3}" Size="25"/>
</ImageButton.Source>
</ImageButton>
Google Play Console - Pre-launch report details - Accesibility tab
Content labeling warning for this component
As already pointed out, you cannot add android:contentDescription="bla bla" directly to the ImageButton one is from the Android platform, the latter is on the Xamarin.Forms level.
If you use the Xamarin Community Toolkit and apply the SemanticEffect.Description="bla bla" that should translate into the contentDescription on Android. If that is not the case, I would be curious to know what the exact warning is that you get after applying it.
I am new to Xamarin (and Xamarin.Forms if they are different). I placed some Entries on page. As soon as I tap one on real Android 4.4 device or inside 4.4 emulator, the application crash with error:
Android.Content.Res.Resources+NotFoundException: 'File res/drawable/abc_ic_clear_material.xml from drawable resource ID #0x7f07001d'
No crash on Android 6.0 real device and 9.0 emulator. I think crash somehow related with ClearButtonVisibility="WhileEditing", because there is clear in missing XML.
<Entry Grid.Row="2" Grid.Column="1" ClearButtonVisibility="WhileEditing" Keyboard="Numeric" Text="15" TextChanged="PriceEntry_TextChanged" />
<Entry Grid.Row="2" Grid.Column="2" ClearButtonVisibility="WhileEditing" Keyboard="Numeric" Text="0" TextChanged="AmountEntry_TextChanged" />
This is how I define Entries in XAML. I want my app to specifically work under Android 4.4. What to do?
I was able to reproduce this issue.
To fix this, please try adding the code below into your MainActivity.cs OnCreate method:
Android.Support.V7.App.AppCompatDelegate.CompatVectorFromResourcesEnabled = true;
Let me know if you have any other questions or concerns.
I'm pretty new to nativescript. I'm trying to figure out how to use the string values from the strings.xml so i can localize my app.
My layout looks like this.
<StackLayout class="page">
<label [text]="#string/a_value"></label>
<Label text="Hello world with tap!" class="yellow"></Label>
<button text="Tap me my friend" (tap)="tapTheButton()" class="red"></button>
<label [text]="text" class="blue"></label>
</StackLayout>
The #string/a_value should get the string from the res/values/strings.xml file.
Any help is welcome!
#string/string_name is not a valid notation when describing NativeScript layouts as it's a strictly Android way of interpolating strings.
You could probably access the resource manager (https://developer.android.com/reference/android/content/Context.html#getResources()) and get the string value for string with name a_value, and then data bind that to your label. That would only work on Android.
There is a NativeScript plugin done by the community that aims to make internationalization abstract, so that it works for both Android and iOS - nativescript-i18n.
I have an existing Android Cordova project which uses an embedded WebView. What this means is that the Activity does not extend CordovaActivity, but instead embeds the SystemWebView and initializes within the onCreate.
The following is currently how this is being done:
Within the layout XML file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
.... other layout elements not related to Cordova....
<org.apache.cordova.engine.SystemWebView
android:id="#+id/cdvWebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
Within the Activity's onCreate:
SystemWebView systemWebView = (SystemWebView) findViewById(R.id.cdvWebView);
CordovaWebView cdvWebView = new CordovaWebViewImpl(new SystemWebViewEngine(systemWebView));
ConfigXmlParser parser = new ConfigXmlParser();
parser.parse(this);
cdvWebView.init(this, parser.getPluginEntries(), parser.getPreferences());
Due to the bug in Lollipop versions 5.0.+ missing the "set" button, I want to implement the Crosswalk plugin into the project.
Unfortunately, all the documentation I'm finding assumes that a typical Cordova install is being used. I haven't been able to get the embedding and initialization of the XWalkWebView working correctly and keep getting a blank white screen.
Has anybody has success with a similar scenario?
I'm not sure, but this might answer your question. It seems to show implementing an XWalkWebView outside of a typical cordova project:
https://github.com/kurli/crosswalk-website/wiki/How-to-use-Crosswalk-Embedded-API-on-Android
I've just started Windows phone 8 development with previous experience of Android Development.
I was just searching if there is any strings.xml like file in windows phone 8 where we can keep strings and specially color codes. Yes i want to keep my own color codes in windows phone 8 project so that i may refer these colors in my Pages XML and in code.
Suggestions are highly appreciated.
Special color codes can be placed in your App.xaml file in the resources part.
Use like the following:
<Application.Resources>
<SolidColorBrush x:Key="ColorWhite"
Color="#FFFFFFFF" />
<ImageBrush x:Key="BackGroundBrush"
ImageSource="SplashScreenImage.jpg" />
<Style x:Key="MyPageStyle"
TargetType="phone:PhoneApplicationPage">
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="Background_WindowsPhone.png"
Stretch="UniformToFill" />
</Setter.Value>
</Setter>
</Style>
</Application.Resources>
In your page you might then use the following:
<phone:ApplicationPage Style="{StaticResource MyPageStyle">
<Grid Background="{StaticResource BackGroundBrush}">
<TextBlock Text="Hi"
Foreground="{StaticResource ColorWhite}" />
</Grid>
</phone:ApplicationPage>