
我有一个库项目,它具有所有功能和一些活动,我还有一个包装器活动,它只有一个JSON配置字符串和一些样式.我将库导入到包装器项目中,并且在包装器项目中,我将库的一个活动设置为启动活动,但是后来得到一个错误,即库中选定的活动不是活动子类或别名.
这是什么意思,我可以纠正这个吗?
应该启动的Activity:
package dk.borgertip.activity;import androID.app.Activity;import androID.content.Intent;import androID.os.Bundle;import androID.vIEw.Menu;import androID.vIEw.MenuItem;import dk.borgertip.R;public class SplashActivity extends Activity { @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_splash); Thread startTimer = new Thread() { @OverrIDe public voID run() { try { sleep(3000); Intent i = new Intent(SplashActivity.this, MainActivity.class); startActivity(i); finish(); } catch (InterruptedException e) { e.printstacktrace(); } } }; startTimer.start(); } @OverrIDe public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_splash, menu); return true; } @OverrIDe public boolean onoptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroIDManifest.xml. int ID = item.getItemID(); //noinspection SimplifiableIfStatement if (ID == R.ID.action_settings) { return true; } return super.onoptionsItemSelected(item); }}项目结构:( Borgertip模块是包含要扩展Activity的活动的库)
带有错误的“编辑配置”对话框:
我做错了什么?
解决方法:
您必须在项目AndroIDManifest.xml中包含该活动
来源官方doc:
In the manifest file of the application project, you must add declarations of all components that the application will use that are imported from a library project. For example, you must declare any <activity>, <service>, <receiver>, <provIDer>, and so on, as well as <permission>, <uses-library>, and similar elements. 总结 以上是内存溢出为你收集整理的Android Studio:错误:SplashActivity不是Activity子类或别名全部内容,希望文章能够帮你解决Android Studio:错误:SplashActivity不是Activity子类或别名所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)