简体   繁体   中英

Android Hello World Error

I'm having difficulty with the Hello World program on Android. 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. 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);

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.R is not imported yet so I import it

Remove import android.R and use yourpackagename.R

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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