Im new in developing apps for android. Ive got this piece of code (which is working fine) (it is part of layout/main.xml):
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
and this code (which is not working well):
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
WTF, guys? If i run the second code I will receive "Sorry! The application x has stopped unexpectedly[...]" If I remove this text view at all it is also working well (i don't interact whit this TextView in my code. What is wrong whit this?
Please help, Chris
EDIT:
This is my only method (it is only beginning of the project ;) )
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
Spinner s = (Spinner) findViewById(R.id.spinner);
ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.days, android.R.layout.simple_spinner_item);
开发者_如何学Goadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s.setAdapter(adapter);
}
and here is the rest of main.xml
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/text2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="Wybierz dzień:"
/>
<Spinner
android:id="@+id/spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:prompt="@string/day_prompt"
/>
</LinearLayout>
Try this code:
<TextView android:text="@+id/TextView01"
android:id="@+id/TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
精彩评论