Android程序安装后在模拟器上不显示,并且控制台显示The launch will only sync the application package on the device!

20 篇文章 0 订阅
6 篇文章 0 订阅

转载地址:http://www.2cto.com/kf/201309/246851.html


初学安卓,今天写了一个小例子,可是eclipse控制台却提示

No Launcher activity found!
The launch will only sync the application package on the device!
但是设备我已经启动了呀,后来慢慢发现,在配置文件 AndroidManifest.xml中,有这两句话:
 
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
< application 
         android:allowBackup = "true" 
         android:icon = "@drawable/ic_launcher" 
         android:label = "@string/app_name" 
         android:theme = "@style/AppTheme"
         < activity 
             android:name = "com.lovemu.textview.MainActivity" 
             android:label = "@string/app_name"
             < intent-filter
                 <!--标识Activity为一个程序的开始--> 
                 < action android:name = "android.intent.action.MAIN" /> 
                 <!--决定应用程序是否显示在程序列表里--> 
                 < category android:name = "android.intent.category.LAUNCHER" /> 
             </ intent-filter
         </ activity
     </ application

 

 
 
其中的<action android:name="android.intent.action.MAIN" />中的MAIN我以为是自己定义的布局管理器XML文件,被我改了,所以启动不了。
可是改过之后,还是出错,经排查,发现android:name="com.lovemu.textview.MainActivity"对应的类文件中,需要:
 
?
1
2
3
4
5
@Override 
     protected void onCreate(Bundle savedInstanceState) { 
         super .onCreate(savedInstanceState); 
         setContentView(R.layout.linearlayout); 
     }

 

 
其中的setContentView(R.layout.linearlayout);我没有加。
至此,程序能运行成功。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值