Gần đây tôi đã cài đặt NetBeans 7.1.1 với plugin NBAndroid 1.11. Sau khi bắt đầu một dự án HelloWorld mới, tôi nhận được lỗi sau từ mã kiểm tra:NetBeans với NBAndroid - không thể tìm thấy biểu tượng setContentView (R.layout.main);
C:\Users\Daniel\Documents\NetBeansProjects\HelloWorld\src\Hello\World\HelloWorldMain.java:14: error: cannot find symbol setContentView(R.layout.main);
Đây là mã nguồn của tôi cho file HelloWorldMain.java:
package Hello.World;
import android.R;
import android.app.Activity;
import android.os.Bundle;
public class HelloWorldMain extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Chức năng setContentView gây ra vấn đề cho một số lý do. Tôi đã kiểm tra tệp R.java cho bất kỳ lỗi nào và dường như không tìm thấy bất kỳ lỗi nào:
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package Hello.World;
public final class R {
public static final class attr {
}
public static final class layout {
public static final int main=0x7f020000;
}
public static final class string {
public static final int app_name=0x7f030000;
}
}
Mọi trợ giúp sẽ được đánh giá cao.
Ồ, trước khi tôi gặp lỗi, tôi cần thêm android.R nhập. Bây giờ nó hoạt động mà không có nó. –