作者:刘占


初学android遇到了各种问题,在这里做一个小的总结,希望对大家遇到同样问题时有一些帮助。也希望大家尽量补充。


1,程序没有错误,运行后却弹出如下

Theapplication has stopped unexpectedly.Please try again

这个问题是个人遇到最多的情况,大多数情况下是程序代码出了问题,但是程序又没有报错,所以要找出问题原因,需要查看Logcat提示的错误,打开Window-Open Perspective-DDMS来查找错误。

(1)Devices:可以查看到当前运行的Emulator和其内运行的应用。(PS:Emulator/Device占用两个(一组)端口,一个为偶数的5554,一个奇数的5555。如果还开启其他的Emulator,则使用的另一组端口是5556,5557,一直到5585.

(2) Emulator control:设置仿真器的硬件

设置当前注册的网络状态(Home,Roaming,UnRegistered,Searching)
数据业务的速度设置:有GSM,GPRS,EDGE,UMTS,HSDPA(3.5G?)
还有载入KML或NMEA文件来模拟GPS数据

(3) 查询Threads,Heap,FileExplorer、重启adb,抓屏等,其他都是在调用adb

(4) 关于logcat

设置打印等级:从Windows->Prereference->android->DDMS->LogginLevel
默认只打印入口线程的信息,射频和Tapi的动作信息要通过adbLogcat -b radio打开,os-events相关的打印通过adb logcat -b events.打开,Log默认被写入到手机的/data/anr/traces.txt文件中。


2,自定义一个listview,想要在同一个Item添加图片、文字和单选按钮比较难,经过上网查找,找到了简单的解决办法

把单选按钮用图片表示即可,然后使用SimpleAdapter放进ListView中,具体代码如下:


simpleAdapter =  new  SimpleAdapter( this , getData(),                  R.layout.picture_info, new  String[] { imageViewIdStr,                          pictureNameIdStr, picturePixelIdStr, radioImageIdStr },                  new   int [] { R.id.imageViewId, R.id.pictureNameId,                          R.id.picturePixelId, R.id.radioImageId });            listView.setOnItemClickListener(new  OnListClickListener());          listView.setAdapter(simpleAdapter);  //////////////////////////////////   private   class  OnListClickListener  implements  OnItemClickListener {            public   void  onItemClick(AdapterView<?> arg0, View arg1,  int  arg2,                  long  arg3) {              // TODO Auto-generated method stub               ChangeRadioImage(selectItemIndex, false );              ChangeRadioImage(arg2, true );              selectItemIndex = arg2;          }  //主要是下面这个函数用来选中和未选中时交换图片的                   private  void ChangeRadioImage( int  position,  boolean  isChangeImage) {              SimpleAdapter tmpSimpleAdapter = simpleAdapter;              HashMap<String, Object> hm = (HashMap<String, Object>) simpleAdapter                      .getItem(position);                if  (isChangeImage) {                  hm.put("radioImageId" , R.drawable.pressed);              } else  {                  hm.put("radioImageId" , R.drawable.press);              }              tmpSimpleAdapter.notifyDataSetChanged();          }  


3,怎么样在后台实现将应用程序卸载:


private void setUninstall(boolean finish, boolean appChanged) {        if(localLOGV) Log.i(TAG, "appChanged="+appChanged);        Intent intent = new Intent();        intent.putExtra(ManageApplications.APP_CHG, appChanged);        setResult(ManageApplications.RESULT_OK, intent);        if(finish) {            finish();         }  


更多相关文章

  1. Android(安卓)8.1 关机充电动画(二)Uboot模式
  2. Android开发Error(建议收藏下来以备不时之需)android.os.Transacti
  3. android 加载大图长图失真或者不显示。
  4. Android显示gif格式图片
  5. Android训练课程(Android(安卓)Training) - 使用Volley传输网络
  6. 高亮的关键字
  7. Android加载图片的几种方式
  8. No Launcher activity found!(明明就有写启动项)
  9. Android(安卓)开源照相和图片选择框架PictureSelector

随机推荐

  1. ART深度探索开篇:从Method Hook谈起
  2. Android知识梳理之Sqlite数据库的使用和
  3. ArcGIS Android MapView离线浏览无限范围
  4. Android Training - 支持不同的设备
  5. 【IOS和Android】Cocos2d-x 集成微信分享
  6. Android 模仿QQ抢红包 listView实现
  7. Android Design(设计)\Get Started(从这里
  8. 【笔记】【从Android(安卓)Guide温习Andr
  9. android 仿ios数字密码解锁界面
  10. 探索新的Android权限模式