简体   繁体   English

Android Hello World错误

[英]Android Hello World Error

I'm having difficulty with the Hello World program on Android. 我在Android上使用Hello World程序遇到困难。 When I load up the blank application, I get the following: 加载空白应用程序时,我得到以下信息:

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

} }

Android.R is not imported yet so I import it, and then I get an error on "activity_main" and "R.menu"... they apparently don't exist. Android.R尚未导入,因此我将其导入,然后出现“ activity_main”和“ R.menu”错误……它们显然不存在。 I tried commenting out the second one and the first one had a suggestion to switch it to switch it to setContentView(R.layout.activity_list_item); 我尝试注释掉第二个,第一个建议将其切换为setContentView(R.layout.activity_list_item);

I only need to make an android program that accepts text input and displays results... that's ALL I need to do... Can someone help me getting this hello world wroking right? 我只需要制作一个可以接受文本输入并显示结果的android程序,这就是我要做的全部……有人可以帮我弄清楚这个世界吗?

Android.R is not imported yet so I import it Android.R尚未导入,因此我将其导入

Remove import android.R and use yourpackagename.R 删除import android.R并使用yourpackagename.R

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM