英文:
Why activity name is not getting resolved in Android Studio
问题
我在我的包下的布局文件夹(layouts)下创建了一个活动的XML文件,但仍然出现以下问题:
package com.alen.cybercpm;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class comrade_login extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_comrade_login);
}
}
activity_comrade_login在代码中显示为红色/错误,但我在我的包中确实有该文件。
我将一个闪屏界面设置为我的主活动(Main Activity),然后调用了这个活动。
英文:
I've an activity XML file created under layouts under my package but still it's complains
package com.alen.cybercpm;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class comrade_login extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_comrade_login);
}
}
activity_comrade_login comes in RED/ERROR but I've that file in my package.
I've a splash screen as my Main Activity. then this activity is called.
答案1
得分: 1
将你的类名从 comrade_login
改为 ComradeLoginActivity
然后执行 clean code
之后进行 Rebuild code
现在执行 clean cache and restart
希望这能帮助你
谢谢!祝编码愉快
英文:
change your Class comrade_login
to ComradeLoginActivity
Then clean code
After this Rebuild code
Now clean chache and restart
Hope it will help you
Thankew! Happy Coding
答案2
得分: 1
只需重新启动您的“Android Studio”。将来可能会出现意外和愚蠢的问题,所以最好的方法是通过重新启动您的“Android Studio”来清除缓存。
英文:
There is nothing seems to be wrong with your code, Just Restart you Android Studio
. You will face such kinds of unexpected and silly problems in future so, the best way is to clear caches
by Restarting Your Android Studio
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论