Позвольте мне сначала объяснить, из чего состоит мое приложение Androïd:
- класс, расширенный из Деятельности. В OnCreate
члене моего класса я пытаюсь получить доступ к TextView, описанному в моем main.xml
файле, используя
"MyTextView=(TextView)findViewById(R.id.myTextView);".
- XML-файл, в котором TextView описывается следующим образом:
<TextView
android:name="@+id/myTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/another TextView"/>
В файле R.java
я вижу, что мой TextView зарегистрирован.
Моя проблема в том, что когда я пытаюсь получить дескриптор TextView с помощью функции findViewById
, я получаю нулевой указатель.
Мне кажется загадкой, потому что я написал другое приложение, в котором мне удалось получить доступ к TextViews. И я не вижу никакой разницы между обоими приложениями !!!
Здравствуйте,
Вот мой полный файл макета:
<TextView
android:name="@+id/Titre"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Application GPS :"/>
<TextView
android:name="@+id/NombreMaxSatellites"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:name="@+id/NombreSatellites"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello Android from NetBeans"/>
<TextView
android:name="@+id/TempsAcquisition"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello Android from NetBeans"/>
<EditText
android:name="@+id/Texte"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Le texte"/>
<Button android:id="@+id/BoutonTexte"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="130dip"
android:layout_marginTop="10dip"
android:text="Terminer"/>
Я могу получить доступ к Button
, но ни TextView
, ни EditText
.
Есть идеи?