package com.example.hi;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.util *;.
public class MainActivity extends Activity {
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
Log.i (Activity_ID, "oncreate has been called");
}
@ 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;
}
}
Why will prompt Activity_ID cannot be resolved to a variable? ?
Before setContentView (R.layout.activity_main); in the main activity_main written is wrong
Entirely in accordance with the textbook written version of the problem?
If yes, how should I change, should pay attention to God after the horse programming? ? ?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Activity_ID not in your Java file definition, you can change it to a string, such as "test".
setContentView (R.layout.activity_main); Here layout can be followed by what name, but keep the source directory / res / layout / below *** xml like you here activity_main.xml.. If you put the name into main.xml, the corresponding code will use R.layout.main.
Reply:
Thank you
Good question residual brain ah, thank anger is not air wing
No comments:
Post a Comment