为什么我的布局不能得到解决? (Android版/ JAVA) [英] Why is my layout unable to be resolved? (Android/Java)
问题描述
好了,我的计划一直工作至今,住编译和一切,我尝试将声音添加到它,所以我创建了一个文件夹原始,并停留在MP3文件。然后我试图使用它,一切都开始变得错误无论出于何种原因。我按Ctrl + Z'd直到它回来之前我尝试添加的声音。该方案还error'd。我删除原始文件夹,还是有错误[标志着下面的程序注意,这仅仅是1类是从我的程序,还有其他的。
Well, my program has been working so far, staying compilable and everything, and I tried to add a sound to it, so I created a folder "raw", and stuck in the mp3 file. Then I tried to use it, and everything started getting errors for whatever reason. I Ctrl+Z'd until it was back to before I tried adding sound. The program still error'd. I deleted the raw folder and there's still errors[marked in the program below] Note that this is only 1 class from my program, there are others.
package scouting.form;
import android.R;//Don't use android.R here; use a fully qualified name for each usage instead - this one only comes up *sometimes...*
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class Login extends Activity {
Button login;
EditText user;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);//Error: activity_login cannot be resolved or is not a field
login=(Button) findViewById(R.id.button1);//NO ERROR even though the next line has an error...
user=(EditText) findViewById(R.id.editText1);//Error: editText1 cannot be resolved or is not a field
login.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent openScouting = new Intent("com.cody.graham.SCOUTING");
startActivity(openScouting);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_login, menu);//Error: activity_login cannot be resolved or is not a field
return true;
}
}
我知道的布局和菜单仍然存在,他们一直在那里的全部时间,我可以打开布局和确认,仍然有布局activity_login,这是在布局文件夹中的编辑文本框和编辑文本框确实有行
I know that the layouts and menus are still there, they have been there the whole time, I can open the layouts and confirm that there is still an Edit Text box in the layout "activity_login" which is in the layout folder and the edit text box does have the line
android:id="@+id/editText1"
在里面。
推荐答案
在上面看到了吗?
import android.R;//Don't use android.R here; use a fully qualified name for each usage instead - this one only comes up *sometimes...
您也许应该小心,评论怎么说。 ;)删除了 android.R
进口,它会使用你的项目的研究
文件来代替,这是在 activity_login
是
You should probably heed what that comment says. ;) Remove the import for android.R
, and it will use your project's R
file instead, which is where activity_login
is.
这篇关于为什么我的布局不能得到解决? (Android版/ JAVA)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!