2012-03-22 2 views
0

Je travaille sur une application pour le système d'exploitation Android en utilisant Android Mono afin que je puisse le programmer en C#. Toutes les choses fonctionnent bien, sauf pour ce seul problème que je reçois.Inconnu Member Error

Fondamentalement, j'ai un exemple de code qui change le texte d'un bouton à chaque clic. J'ai essayé de modifier l'exemple de code afin qu'au lieu de changer le bouton, il change le texte d'un objet xml textview et, après avoir obtenu cette erreur, je l'ai remplacé par un objet edittext. Je l'ai remplacé parce qu'il me semblait logique d'éditer un edittext plus facilement qu'un textview.

Anywho, j'ai eu la même erreur au même endroit. Chaque fois que j'essaie de changer le textview.text ou edittext.text, le programme se bloque et je reçois l'erreur « Unknown membre »

Voici la partie C# du code.

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++; 
}; 
}; 

ici sont les sections XML qui sont touchés: de l'Main.xml:

<Button 
android:id="@+id/CurrentButton" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/Amp" 
/> 

de l'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> 

Répondre

0

Cela ressemble à un problème simple avec votre fichier XML.

Dans votre AmpScreen.xml sur l'élément EditText:

id="@+id/ampdata" 

devrait être:

android:id="@+id/ampdata" 
+0

Merci = D qui a résolu mon problème. – Zach