For some reason when I design this Android app, the .java file is not finding the main_activity and will not run the app.
Where it says: R.activity.main_activity there is a red line under "Main_Activity".
Does anyone know why, how can I fix this?
Thanks!
package com.test.helloworld;
import android.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.EditText;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText num = (EditText)findViewById(R.id.num);
}
you imported android.R; , the resource-id file for the android SDK. you will probably want to import your own R.java that was generated for you.
Import as
import android.com.test.helloworld.R;
instead of
import android.R;
Also clean your project and also run it again.
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.