0
これについてお手伝いできますか? このエラーは理解できません。 :(未解決の例外Xamarin.Androidで
アクティビティコード:
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace Phoneword2
{
[Activity(Label = "Phone Word", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
EditText phoneNumberText = FindViewById<EditText>(Resource.Id.PhoneNumberText);
Button translateButton = FindViewById<Button>(Resource.Id.TranslateButton);
Button callButton = FindViewById<Button>(Resource.Id.CallButton);
callButton.Enabled = false;
// Add code to translate number
string translatedNumber = "";
translateButton.Click += (object sender, EventArgs e) =>
{
// Translate user's alphanumeric phone number to numeric
translatedNumber = Core.PhonewordTranslator.ToNumber(phoneNumberText.Text);
if (String.IsNullOrWhiteSpace(translatedNumber))
{
callButton.Text = "Call";
callButton.Enabled = false;
}
else
{
callButton.Text = "Call " + translatedNumber;
callButton.Enabled = true;
}
};
callButton.Click += (object sender, EventArgs e) =>
{
// On "Call" button click, try to dial phone number.
var callDialog = new AlertDialog.Builder(this);
callDialog.SetMessage("Call " + translatedNumber + "?");
callDialog.SetNeutralButton("Call", delegate {
// Create intent to dial phone
var callIntent = new Intent(Intent.ActionCall);
callIntent.SetData(Android.Net.Uri.Parse("tel:" +
translatedNumber));
StartActivity(callIntent);
});
callDialog.SetNegativeButton("Cancel", delegate { });
// Show the alert dialog to the user and wait for response.
callDialog.Show();
};
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
}
}
}
`
そしてこれはmain.axmlコードです:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:text="Enter a Phoneword"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView1" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/PhoneNumberText" />
<Button
android:text="Translator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/TranslateButton" />
<Button
android:text="Call"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/CallButton" />
</LinearLayout>
その2つのボタンと、プレーンテキストを含む... することができます翻訳ボタンをクリックすると、コールボタンのテキストが更新されます。 コールボタンを押すと、ターゲット番号に電話をかけます。
新しい写真を参照してください。 –
@SeyedMiladEmadi - これは、コードの特定の行でエラーが発生してはならないので奇妙です。私は2つのことを提案することができます:まず、ソリューションをきれいにして、それを再構築します。次に、問題に直面しているサンプルプロジェクトを共有できますか?私はそれをさらに調べるために自分自身を実行しようとすることができます –
私は最初のオプションはエラーが特定の行に加えてエラーの行に加えて変更されていないため動作している気がします... 24!したがって、クリーニングと再構築(Visual Studioを再起動することさえ可能)は機能するはずです。 –