Showing full text in Pin's label in xamarin - xamarin

I want to display text in multiple lines in the pin's label when it is clicked, but when I have a very long text to be displayed in Address it shows me only a part of it and rest of it remains hidden eg: 'Street 12A...'.
How can I make the label to display the whole text on clicking it and if possible then in multiple lines using Xamarin.Forms.Maps.
var pin = new Pin
{
Type = PinType.Place,
Position = position,
Label = "Label Name",
Address = "some text..........."
};
map.Pins.Add(pin);

You would be to create a custom render for map on each platform to replace the standard iOS pin annotations, Android pin markers, etc...
Xamarin has a full guide for creating custom pin annotations/markers and thus you can create the UI elements you need to display your full text.
Ref: https://developer.xamarin.com/guides/xamarin-forms/custom-renderer/map/

Related

Access ListView item text (FMX)

I have a TListView and when the user clicks on the image of an item (big green dot in picture below) i want to copy the item text ("russtest.cfg") and subitem text ("My Device, 1991") to display in a ShowMessage. I can't find how to do it in C++ Builder but this link shows how in Delphi.
Below is the code i've tried in the TListView's ItemClickEx method:
TListItem* item;
item = ListView1->Items->Item[ItemIndex];
UnicodeString s;
s = item->ToString();
ShowMessage(s);
But it brings back this:
EDIT 1: Added the code i use to populate the ListView:
TListViewItem* item2Add = Form1->ListView1->Items->Add();
Form1->ListView1->BeginUpdate();
item2Add->Text = mystring3; // e.g. "russtest.cfg"
item2Add->Detail = mystring2; // e.g. "My Device, 1991"
item2Add->ImageIndex = 1; // big green dot
Form1->ListView1->EndUpdate();
Your need to typecast the TListItem* to TListViewItem*, then you can access its Text property:
TListViewItem* item = static_cast<TListViewItem*>(ListView1->Items->Item[ItemIndex]);
String s = item->Text;
ShowMessage(s);

Xamarin / iOS - How to disable tab keycode from hardware keyboard

I have a circumstance where a bluetooth barcode scanner is acting as a hardware keyboard in an Xamarin Forms application. The barcodes are encoded as such to contain a bit of information that needs to be parsed into different fields.
Unfortunately, some of the data is a tab character. iOS receives this hardware event in my app and once the tab pumps through, the next input field is focused and the barcode data continues to dump into that (the barcode scanner reads the data through "sequentially", as if to simulate you were typing it in).
At any rate; I'm having a heck of a time intercepting the "tab" character in an Entry (UITextView) in Xamarin/iOS.
I've set up an extension on Entry and associated a custom renderer with it (MyRenderer : EntryRenderer). Searching suggests that using Control.ShouldChangeTextInRange should work for character remapping, but the tab event happens on a different level it appears.
How can I stop a hardware keyboard "Tab" character in iOS from focusing onto the next field?
You could use KeyCommands to filter the Tab action in your EntryRenderer like this:
public override UIKeyCommand[] KeyCommands
{
get
{
UIKeyCommand newForwardKeyCommand = UIKeyCommand.Create(new NSString("\t"), 0, new ObjCRuntime.Selector("Excute"));
UIKeyCommand newBackKeyCommand = UIKeyCommand.Create(new NSString("\t"), UIKeyModifierFlags.Shift, new ObjCRuntime.Selector("Excute"));
UIKeyCommand[] keyCommands = { newForwardKeyCommand, newBackKeyCommand };
return keyCommands;
}
}
[Export("Excute")]
private void Excute()
{
Console.Write("Excute!");
}
Reference:https://stackoverflow.com/a/30876304/5474400

Xamarin Android : Retain data on activity change and come back

I'm developing an app in Xamarin.android where in I want to retain the data of Edit Text, spinners etc. whenever i revisit to that activity. E.g.
Activity A contains Edit Text, Spinners.
I navigate to Activity B from Activity A, and whenever I come back to Activity A from B I want to retain those values of Edit Text and Spinners.
I tried using Put Extra and Get Extra, but as there are multiple values this approach seems to be wrong.
var activity2 = new Intent (this, typeof(Activity2));
activity2.PutExtra ("MyData", "Data from Activity1");
StartActivity (activity2);
Also OnSaveInstanceState and OnRestoreInstanceState is not working out for me as I'm using Fragments in my Activity A
Please Guide
Can't your fragments save their own data using Fragment.onSaveInstanceState ?
in your case you need to save this temp data in Shared Preference
here is example
ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);
ISharedPreferencesEditor editor = prefs.Edit();
editor.PutInt(("number_of_times_accessed", accessCount++);
editor.PutString("date_last_accessed", DateTime.Now.ToString("yyyy-MMM-dd"));
editor.Apply();
save what ever you want int or string
and when you load you activity retrieve this data and set it to your views
ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);
string passedString = prefs.GetString(key, defValue);
// here set retured data to your view
// Ex : YourEditText.Text = passedString
hope this help

Add a Clear button functionality in Custom Keyboard using Swift

I use a custom keyboard which contains a delete and a clear button.I can able to delete the letters using this code
let obj = UIInputViewController()
(obj.textDocumentProxy as UIKeyInput).deleteBackward()
Is it any keyword available to clear whole text in a textfield.
NB: I found this link but it is not apt for my requirement
There is no keyword available for deleting the whole text in the textfield through custom keyboard.
To clear all the text that the UITextDocumentProxy object can access in the textfield before the cursor position
if let word:String = self.textDocumentProxy.documentContextBeforeInput
{
for _: Int in 0 ..< word.characters.count {
self.textDocumentProxy.deleteBackward()
}
}
To delete the text after cursor position, you have to move the cursor forward to delete it.

can't set a property for flex container in segment widgets

I am new to Kony framework. Now i am going through Widget. There i came across Segment widgets using I would create a flex container with some labels and textbox.
My UI design are :
1. I Created a segment and set a flex container with some labels and text box in that segment
2. After that I turn off the flex container visible
3. And I type a code like :
function flex()
{
frmAssign.sgmt1.flex1.isVisible = true;//to show flex as visible but it does not read the property of that flex
}
In simple terms just If I click segment first row flex container isVisible should be true
enter image description here
want to achieve this design in kony
Try change frmAssign.sgmt1.flex1.isVisible = true;
frmAssign.sgmt1.flex1.setVisibility(true);
You cannot access the widget of segment directly.
You have to create a property (eg:isVisible) in Master Data of the segment.
initial Value of this property would be "false",
Then change the value as you per your need.
To change properties in segment data you have change the properties in array which you have set to data of segment.
Basically idea is
if you are using masterdata then you need to read the data change
property values and reassign.
if you are dynamically setting data
then you need to change that array and reassign
// always check for Null for selecteindex
//Note keep your existing properties and just change isVisible to true
var selecteindex= frmAssign.sgmt1.selectedRowIndex;
var segData = frmAssign.sgmt1.data[selecteindex];
segData[selecteindex] =("YourFlexName": {
"text": "CButton1",
"isVisible":true
});
form1.segment1.setDataAt(segData,selecteindex);
The right way to do this is :
var selectedIndex= frmAssign.sgmt1.selectedRowIndex;
var rowData = frmAssign.sgmt1.data[selectedIndex];
rowData["flex1"]["isVisible"] = true;
form1.segment1.setDataAt(rowData, selectedIndex);

Resources