xamarin.android

Several item templates in one listbox in mvvmcross Android

坚强是说给别人听的谎言 提交于 2019-12-11 06:37:52
问题 I use MvvmCross framework. I want to use different item templates in one listview depending on ViewModel type. For example I have the list of AnimalViewModels. And I want KittenViewModel and PuppyViewModel look different. I found out how to do this in iOS and WP7. How to implement this in Android. Thank you 回答1: A few of the samples show how to use cell type selection. See: polymorphic lists in https://github.com/slodge/MvvmCross-Tutorials/tree/master/Working%20With%20Collections grouped

Error “Frame not in module.” in Xamarin.Forms - Android project

你离开我真会死。 提交于 2019-12-11 06:24:46
问题 Whenever it comes to this line, this error appears: using (var client = new HttpClient()) { var json = await client.GetStringAsync("http://mvalivros.azurewebsites.net/api/livros"); var livros = JsonConvert.DeserializeObject<List<Model.Livro>>(json); return livros; } A new tab appears in VS that says "Frame not in module." It happens whenever the thread arrives at the using line. Frame not in module This is code complete... using Newtonsoft.Json; using System; using System.Collections; using

How to assign OnActivityResult values to the Listview?

ⅰ亾dé卋堺 提交于 2019-12-11 06:21:15
问题 I have a Listview and Click Events in the respective listItems and need to get result back from the click events and populate on the List. My BaseAdapter class is public class RemnantListAdapter : BaseAdapter<InventorySlabs> { private PartialInventory context; private List<InventorySlabs> RemnantList; public RemnantListAdapter(PartialInventory partialInventory, List<InventorySlabs> remnantList) { this.context = partialInventory; this.RemnantList = remnantList; } public override InventorySlabs

How to display Date like device date time format in Android

眉间皱痕 提交于 2019-12-11 06:19:55
问题 I have a date: var date = new DateTime(2017,6,14,13,0,0); and a textview to display it. I'd like to display as ' 14/06/2017 13:00 ' when I set Date and time of the device to ' Use 24-hour format ' and ' 16/06/2017 1:00 PM ' when I un-check ' Use 24-hour format '. How can I do? Thank you! 回答1: On Xamarin.Android it is a bit different than on Android as described in Muhammads answer: var date = new DateTime(2017, 6, 14, 13, 0, 0); var is24hour = Android.Text.Format.DateFormat.Is24HourFormat

Xamarin Forms: backgroundImage from external storage

爱⌒轻易说出口 提交于 2019-12-11 06:17:53
问题 I am developing a Xamarin Form s which writes successfully an image to external storage and then should use it as Background of a ContentPage. In the constructor of the ContentPage I wrote this: this.BackgroundImage = "/storage/emulated/0/DCIM/D72D01AEF71348CDBFEED9D0B2F259F7.jpg" but the background image never shows. I checked the Android Manifest and the permissions of read and write external storage are set correctly. What am I missing? 回答1: The problem with your code is that

Notification.Extra.GetString returns empty while it contains data

蹲街弑〆低调 提交于 2019-12-11 06:17:30
问题 I have a NotificationListener for my app that is supposed to listen to media player notifications like Spotify or GPM. This is the code for the OnListenerConnected override: public override void OnListenerConnected() { base.OnListenerConnected(); Log.WriteLine(LogPriority.Info, "SmartLyrics", "OnListenerConnected (NLService): Listener connected"); foreach (StatusBarNotification sbn in GetActiveNotifications()) { if (sbn.Notification.Category == "transport") { Log.WriteLine(LogPriority.Info,

Getting ViewRootImpl$CalledFromWrongThreadException when calling invalidate function in Custom Surface View

╄→гoц情女王★ 提交于 2019-12-11 06:17:18
问题 I am creating a moving animation for my Card Game, for this i have created a custom surface view, while calling invalidate method inside my Surface View i am getting following exception android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. My code: Thread Class class MySurfaceViewThread:BaseThread { private MySurfaceView mysurfaceview; private ISurfaceHolder myThreadSurfaceHolder; bool running; public

Xamarin Android ListView select item and change row color

笑着哭i 提交于 2019-12-11 06:15:17
问题 I'm new to xamarin and I've been looking everywhere for a way to select an item in a ListView and change the color of the row to let the user know which row is selected. Here is what I got private void FormsListViewOnItemClick(object sender, AdapterView.ItemClickEventArgs itemClickEventArgs) { _cicoListView.SetItemChecked(itemClickEventArgs.Position, true); for (var i = 0; i < _ciCos.Count; i++) { if (itemClickEventArgs.Position == i) { _selectedId = ((CicoModel)_cicoListView.Adapter.GetItem

How to get path of font file from asset folder and how to use that path to set SKTypeface in xamarin android?

邮差的信 提交于 2019-12-11 06:08:02
问题 I am working in native xamarin andorid. I am facing issue to set custom font. I am using "SkiaSharp" plugin to generate canvas view. That plugin is inside PCL so that can be use in both android and ios. I have one .ttf file in my "Assets" folder. I generate font path using following code. string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); string FontPath = System.IO.Path.Combine(path, "Myfile.ttf"); this Path I send to PCL to set "SKTypeface" paint

Unable to add Xamarin Facebook SDK package in Xamarin.Forms Droid solution due to dependencies

喜夏-厌秋 提交于 2019-12-11 06:07:50
问题 I'm struggling adding the Facebook Android package (tried both with Nuget and component manager) to the Droid solution on my Xamarin.Forms project. It seems there's some kind of incompatibility between the package Xamarin.Forms and its dependencies and Facebook SDK package dependencies. If I remove the package Xamarin Forms (and all its dependencies), the Facebook Android SDK package installs OK (with dependencies), but I can't add Forms after adding Facebook SDK because of dependencies