Question

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?

Was it helpful?

Solution

Android.R is not imported yet so I import it

Remove import android.R and use yourpackagename.R

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top