Hi, Made a very basic xml file to try and access a simple button widget. The main.xml file is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"/>
<TextView android:text="Heading Text"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<Button android:text="Button Text"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
The Java program is
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
public class TestButton extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button myButton = (Button)findViewById(android.R.id.Button01);
}
}
The error on the 'Button' line is:
Button01 cannot be resolved or is not a field
Any ideas, what very basic mistake am I making :( :(
Oliver