I'm new at android programming, I'm now trying to make some buttons, I configured these buttons using the following code:
The MainActivity class :
public class MainActivity extends Activity
{
/** Called when the activity is first created. */
Button st,nd,center;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
st = (Button)findViewById(R.id.st);
st = (Button)findViewById(R.id.center);
st = (Button)findViewById(R.id.nd);
}
}
and the XML Layout:
<?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"
android:background="@drawable/background"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello from animation!!"
/>
<button android:layout_width="100dp"
android:layout_height="50dp"
android:text="1st half"
android:id="@+id\st"
/>
// and the other two points defined the same way
</LinearLayout>
And i got that syntax error:
error: Error: No resource type specified (at 'id' with value '@+id\st').
// and the same error with the other two buttons
HINT: The R class
is imported and accessible from the MainActivity
class but it can't read R.id
.