Java 未指定资源类型(在';id';处,值为&';@&&+;id\st&';)
我是android编程新手,我现在尝试制作一些按钮,我使用以下代码配置了这些按钮: 主要活动课程:Java 未指定资源类型(在';id';处,值为&';@&&+;id\st&';),java,android,r.java-file,Java,Android,R.java File,我是android编程新手,我现在尝试制作一些按钮,我使用以下代码配置了这些按钮: 主要活动课程: public class MainActivity extends Activity { /** Called when the activity is first created. */ Button st,nd,center; @Override public void onCreate(Bundle savedInstanceState) {
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);
}
}
以及XML布局:
<?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>
提示:导入
R类
并可从MainActivity
类访问,但它无法读取R.id将按钮
替换为按钮
和android:id=“@+id\st”
替换为android:id=“@+id/st”
用按钮替换按钮
和android:id=“@+id\st”
用android:id=“@+id/st”
用按钮替换按钮
和android:id=“@+id\st”
用android:id=“@+id/st”替换
用按钮替换按钮
,android:id=“@+id\st”
用android:id=“@+id/st”
你用按钮代替按钮
。它区分大小写。
在android:id
中,通过/
替换\
这是正确的代码:
<Button android:layout_width="100dp"
android:layout_height="50dp"
android:text="1st half"
android:id="@+id/st"
/>
用这个替换你的按钮代码,它应该可以工作你用按钮
代替按钮
。它区分大小写。
在android:id
中,通过/
替换\
这是正确的代码:
<Button android:layout_width="100dp"
android:layout_height="50dp"
android:text="1st half"
android:id="@+id/st"
/>
用这个替换你的按钮代码,它应该可以工作你用按钮
代替按钮
。它区分大小写。
在android:id
中,通过/
替换\
这是正确的代码:
<Button android:layout_width="100dp"
android:layout_height="50dp"
android:text="1st half"
android:id="@+id/st"
/>
用这个替换你的按钮代码,它应该可以工作你用按钮
代替按钮
。它区分大小写。
在android:id
中,通过/
替换\
这是正确的代码:
<Button android:layout_width="100dp"
android:layout_height="50dp"
android:text="1st half"
android:id="@+id/st"
/>
用这个替换按钮代码,它应该可以工作代码中有一些语法错误
首先使用按钮
而不是按钮
在id之后使用/而不是\
<Button android:layout_width="100dp"
android:layout_height="50dp"
android:text="1st half"
android:id="@+id/st"
/>
您的代码中有一些语法错误
首先使用按钮
而不是按钮
在id之后使用/而不是\
<Button android:layout_width="100dp"
android:layout_height="50dp"
android:text="1st half"
android:id="@+id/st"
/>
您的代码中有一些语法错误
首先使用按钮
而不是按钮
在id之后使用/而不是\
<Button android:layout_width="100dp"
android:layout_height="50dp"
android:text="1st half"
android:id="@+id/st"
/>
您的代码中有一些语法错误
首先使用按钮
而不是按钮
在id之后使用/而不是\
<Button android:layout_width="100dp"
android:layout_height="50dp"
android:text="1st half"
android:id="@+id/st"
/>