package dylan.app02;import android.app.Activity;
import android.os.Bundle;public class Activity02 extends Activity {
/** Called when the activity is first created. */
private Button myButton=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myButton=(Button)findViewById(R.id.myButton);
}
}
import android.os.Bundle;public class Activity02 extends Activity {
/** Called when the activity is first created. */
private Button myButton=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myButton=(Button)findViewById(R.id.myButton);
}
}
Description Resource Path Location Type
Button cannot be resolved to a type Activity02.java /Activity02/src/dylan/app02 line 8 Java Problem
Button cannot be resolved to a type Activity02.java /Activity02/src/dylan/app02 line 13 Java Problem
Button cannot be resolved to a type Activity02.java /Activity02/src/dylan/app02 line 13 Java Problem
有个空格
他贴出来的错是Button cannot be resolved to a type,是代码里少了个包
还有就是main.XML需要<Button android:id = "@+id/myButton"
...
/>