No resource type specified (at 'id' with value '@+id\st')
Posted
by
Refaat
on Stack Overflow
See other posts from Stack Overflow
or by Refaat
Published on 2013-11-13T09:47:33Z
Indexed on
2013/11/13
9:53 UTC
Read the original article
Hit count: 300
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
.
© Stack Overflow or respective owner