How to create a NumericTextbox in .axml in Xamarin.Android
In General, we have get the view of NumericTextBox is only from Activity class file. Here SfNumericTextBox provides a support to get the view of same from layout file. The following steps are required to get the view of NumericTextBox from layout file.
Step 1: Create a Xamarin.android solution with needed assembly
Step 2: Create a new layout file to add our Syncfusion ‘s NumericTextBox control
Step 3: Create an instance of NumericTextBox in layout file as well as add this layout as currently viewing activity by setting this layout as “SetContentView” as follows
Layout File:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"> <com.syncfusion.numerictextbox.SfNumericTextBox android:id="@+id/layoutNumeric" android:layout_height="wrap_content" android:layout_width="fill_parent" /> </LinearLayout>
MainActivity.cs File:
using Android.App;using Android.Widget;using Android.OS;namespace NumericTextBoxLayout{[Activity(Label = "NumericTextBoxLayout", MainLauncher = true, Icon = "@mipmap/icon")]public class MainActivity : Activity{ protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.NumericLayout); }}}
Step 4: Only the declaration of control is allowed in layout file. Properties have been set by created an instance of NumericTextBox with layout control id.
using Android.App; |