ad

找不到符号变量activity_main-英雄云拓展知识分享

匿名投稿 211 2024-01-22

我是新的。每当我尝试构造并运行此代码时,就会出现此消息。

这是XML代码:

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

找不到符号变量activity_main-英雄云拓展知识分享

android:orientation="vertical"

tools:context="com.example.android.justjava.MainActivity">

<TextView

android:id="@+id/quantity_text_view"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="quantity"

android:textAllCaps="true"

android:textSize="16sp"

android:textColor="@android:color/black"

android:layout_marginLeft="16dp"

android:layout_marginTop="16dp"/>

<TextView

android:id="@+id/zero_text_view"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="0"

android:layout_below="@+id/quantity_text_view"

android:textSize="16sp"

android:textColor="@android:color/black"

android:layout_marginLeft="16dp"

android:layout_marginTop="16dp"/>

<Button

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="order"

android:textAllCaps="true"

android:layout_below="@+id/zero_text_view"

android:layout_marginLeft="16dp"

android:layout_marginTop="16dp"

android:onClick="submitOrder"/>

这是Java代码:

/***重要:在下面添加裹。软件包名称可以在项目的AndroidManifest.xml文件中找到。 *这是我们的示例使用的软件包名称: * *软件包com.example.android.justjava; * */

导入Android.r;导入android.os.bundle;导入android.support.v7.App.AppCompatactivity;导入android.view.view;导入android.widget.textview;

导入静态com.example.android.justjava.r.id.quantity_text_view;

/***此利用显示订购咖啡的定单表格。 */公共类MainActivity扩大了AppCompatactivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main_activity);

}

/**

* This method is called when the order button is clicked.

*/

public void submitOrder(View view) {

display(1);

}

/**

* This method displays the given quantity value on the screen.

*/

private void display(int number) {

TextView quantityTextView = (TextView) findViewById(R.id/quantity_text_view);

quantityTextView.setText("" + number);

} }

这是毛病的图片:

https://i.stack.imgur.com/tlrui.png

请帮我

看答案
  1. 检查您的XML文件名。
  2. 检查您的进口声明
  3. 清洁并再次构造项目。

  4. 如果以上不起作用,请删除R文件并清算


🚀🌟 点击注册 免费试用超级应用平台-英雄云企业级hpapaas 🌟🚀 😃👉🌐

免责声明:

网址(www.yingxiongyun.com)发布的材料主要源于独立创作和网友匿名投稿。此处提供的所有信息仅供参考之用。我们致力于提供准确且可信的信息,但不对材料的完整性或真实性作出任何保证。用户应自行验证相关信息的正确性,并对其决策承担全部责任。对于由于信息的错误、不准确或遗漏所造成的任何损失,本网址不承担任何法律责任。本网站所展示的所有内容,如文字、图像、标志、音频、视频、软件和程序等的版权均属于原创作者。如果任何组织或个人认为网站内容可能侵犯其知识产权,或包含不准确之处,请即刻联系我们进行相应处理。

标签:爪哇 安卓
上一篇:缺少依赖项lua-cjson&gt; = 2.1.0用于安装fblualib?-英雄云拓展知识分享
下一篇:rxjava:仅在给定期间的第一项时发出-英雄云拓展知识分享
相关文章

 发表评论

暂时没有评论,来抢沙发吧~

×