0
因此,我正在Xamarin中爲學校製作C#android應用程序,並且在某些時候用戶需要輸入IBAN號碼。 我想檢查輸入是否等於4次4個數字與他們之間的破折號(例如1234-1234-1234-1234), 悲傷我不知道如何做到這一點,我還沒有找到任何可以幫助我, 至今。Android自定義數字輸入驗證
這是我的活動,我需要檢查「mTxtIBAN」的輸入是否等於IBAN號碼。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace LoginSystem
{
[Activity (Label = "SubDetailsBankActivity")]
public class SubDetailsBankActivity : Activity
{
private Button mBtnContinue;
private EditText mTxtIBAN;
private EditText mTxtBIC;
private TextView mIBANWarning;
private TextView mBICWarning;
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
SetContentView (Resource.Layout.SubBankDetails);
// Create your application here
string email = Intent.GetStringExtra ("Email") ?? "Data not available";
string firstName = Intent.GetStringExtra ("FirstName") ?? "Data not available";
string lastName = Intent.GetStringExtra ("LastName") ?? "Data not available";
string streetNumber = Intent.GetStringExtra ("StreetNumber") ?? "Data not available";
string cityCode = Intent.GetStringExtra ("CityCode") ?? "Data not available";
string country = Intent.GetStringExtra ("Country") ?? "Data not available";
mBtnContinue = FindViewById<Button> (Resource.Id.btnContinue);
mTxtIBAN = FindViewById<EditText> (Resource.Id.IBAN);
mTxtBIC = FindViewById<EditText> (Resource.Id.BIC);
mIBANWarning = FindViewById<TextView> (Resource.Id.IBANtext);
mBICWarning = FindViewById<TextView> (Resource.Id.BICtext);
mBtnContinue.Click += (object sender, System.EventArgs e) =>
{
if (mTxtIBAN.Text.Length != 0 && mTxtBIC.Text.Length != 0) {
var newSub = new Intent(this, typeof(SubDetailsComplete));
newSub.PutExtra ("Email", email);
newSub.PutExtra ("FirstName", firstName);
newSub.PutExtra ("LastName", lastName);
newSub.PutExtra ("StreetNumber", streetNumber);
newSub.PutExtra ("CityCode",cityCode);
newSub.PutExtra ("Country", country);
newSub.PutExtra ("IBAN", mTxtIBAN.Text);
newSub.PutExtra ("BIC", mTxtBIC.Text);
StartActivity (newSub);
}
if (mTxtIBAN.Text.Length == 0){
mIBANWarning.Text = "Fill in your IBAN number!";
}
if (mTxtBIC.Text.Length == 0){
mBICWarning.Text = "Fill in your BIC number!";
}
};
}
}
}
任何幫助將不勝感激。 預先感謝您,祝您有美好的一天。
希望你會知道它...嘗試使用正則表達式來匹配你的字符串.... – Srinivasan
@Srinivasan我不知道這一點,但我會查找它:) – yoshiMannaert