Я работаю над приложением для ОС Android, используя Android Mono, поэтому я могу запрограммировать его на C #.Все работает хорошо, за исключением одной проблемы, которую я получаю.
По сути, у меня есть пример кода, который меняет текст кнопки при каждом нажатии.Я попытался изменить пример кода так, чтобы вместо изменения кнопки он изменял текст объекта xml textview и, получив эту ошибку, я заменил его объектом edittext.Я заменил его, потому что казалось здравым смыслом, что редактирование текста редактирования было бы легче, чем просмотр текста.
В любом случае, я получил ту же ошибку в том же месте.Всякий раз, когда я пытаюсь изменить textview.text или edittext.text, программа зависает, и я получаю сообщение об ошибке «Неизвестный участник».
Вот фрагмент кода на C #:
Button ampButton = FindViewById<Button>(Resource.Id.CurrentButton);
ampButton.Click += delegate
{
SetContentView(Resource.Layout.AmpScreen);
Button ampButton2 = FindViewById<Button>(Resource.Id.CurrentButtonamp);
EditText ampData = FindViewById<EditText>(Resource.Id.ampdata);
ampButton2.Click += delegate
{
ampButton2.Text = string.Format("{0} clicks!", count2++);
ampData.Text = ampButton2.Text;
//string temp = Convert.ToString(count2) + " clicks!";
//ampData.Text=temp;
//count2++;
};
};
Вот разделы XML, на которые влияют: Из файла Main.xml:
<Button
android:id="@+id/CurrentButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Amp"
/>
Из файла AmpScreen.xml:
<?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"
>
<ImageView id="@+id/ampImage"
android:layout_width="50px"
android:layout_height="50px"
android:layout_gravity="center"
android:src="@drawable/amp"/>
<EditText id="@+id/ampdata"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Loading"/>
<Button
android:id="@+id/CurrentButtonamp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Re-scan"
/>
<Button
android:id="@+id/homeButtonamp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Back"
/>
</LinearLayout>