I have created an EntryElement in which the user enters a phone number.How can I add a button at the end of the element so that the user can press the button and make a call?
Asked
Active
Viewed 387 times
2
-
Why not make that an answer instead of a comment? It's exactly what to do! – Krumelur Mar 06 '12 at 18:36
2 Answers
0
I know this doesn't exactly answer the question but I struggled for quite a while until I found the answer by @Janub which put me on the right track. Here is the code that I currently have working.
public class NextNumericCell : EntryElement
{
readonly EventHandler handler;
public NextNumericCell (string caption, string placeholder, string value, EventHandler onClick ) : base(caption,placeholder,value)
{
handler = onClick;
}
protected override UITextField CreateTextField (CGRect frame)
{
var textField = base.CreateTextField (frame);
var toolBar = new UIToolbar (new CGRect (0, 0, frame.Width, 35));
var spacerButton = new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace);
var buttonTitle = ReturnKeyType == null ? "SetButtonTitle" : ReturnKeyType.ToString ();
var nextButton = new UIBarButtonItem (buttonTitle, UIBarButtonItemStyle.Plain, handler);
toolBar.Items = new UIBarButtonItem [] { spacerButton, nextButton };
textField.InputAccessoryView = toolBar;
return textField;
}
}

R. J.
- 437
- 5
- 15
0
You need to create a new element that is a subclass of an EntryElement, override the get cell method and add to the accessoryView the button .

Janub
- 1,594
- 14
- 26
-
1I you dont know how to get back to the application after that the conversation is finished, then take a look at this. http://stackoverflow.com/questions/9264065/is-it-possible-to-go-back-automatically-into-the-application-after-calling-a-num – MemoDreamer Mar 07 '12 at 08:25
-
The property AccessoryView of the cell is null.Instead I added the button to the subviews of the cell as `_cell.Subviews[0].AddSubview(btn)`. Is this the same? – Aristeidis Bampakos Mar 13 '12 at 10:19