1:在清单文件(Manifest)中加入权限时要注意,如下例:

<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>

<uses-permission  android:name="android.permission.CHANGE_WIFI_STATE"/>

而非:

<uses-permission

android:name="android.permission.CHANGE_NETWORK_STATE"

android:name="android.permission.CHANGE_WIFI_STATE"/>

写成后一种情况将会报如下错误:

已经为元素 "uses-permission" 指定绑定到名称空间 "http://schemas.android.com/apk/res/android" 的属性 "name"。

2:Replace "..." with ellipsis character (…, &&;#8230;) ?

按照提示即可解决,提示的意思即为,用省略号的字符形式(…, &&;#8230;)?替换省略号"..."(这个省略号是由英文状态下输入的三个圆点),其中(…, &&;#8230;)?貌似是一个正则表达式(本人不太确定),解决方法有两个:

第一种方法:跳到中文输入法下,按shift+^打出省略号

第二种方法:直接将省略号替换为【…】

猜测原因:可能是在字符编码的情况下,省略号可以更好的显示吧

3:这里记录的只能算是一个小小的经验,不知道有时候你遇到过这样的问题没有,当你引用一个drawable资源,比如图片资源时,你引用后系统报错,说找不到这样的资源,而且有时候你即使把你的图片重命名了也不行,这个时候建议你仔细检查你的图片名称,有时候在图片的名称里面会偶然加入一些空格,英文状态下的空格有时候你不细心去看,还真的难以发现那么一个小小的空格,但是可能这个空格就会一直导致你的编译器给你报错。遇到了这种情况,如果确保了你的命名格式对的话,希望你可以仔细检查一下名字,看看有没有写错。

4:ADT警告:This tag and its children can be replaced by one <TextView/> and a compound drawable

下面的解决方案来自:http://stackoverflow.com/questions/3214424/android-layoutopt-this-tag-and-its-children-can-be-replaced-by-one-textview

以一个例子呈现:

修改之前的布局文件

  1. <LinearLayout
  2. android:layout_width="fill_parent"
  3. android:layout_height="wrap_content"
  4. android:layout_marginTop="10dp"
  5. android:padding="5dp" >
  6. <TextView
  7. android:layout_width="wrap_content"
  8. android:layout_height="wrap_content"
  9. android:layout_weight="1"
  10. android:text="My Compound Button" />
  11. <ImageView
  12. android:layout_width="wrap_content"
  13. android:layout_height="wrap_content"
  14. android:src="@drawable/my_drawable" />
  15. </LinearLayout>
修改之后的布局文件
  1. <TextView
  2. android:layout_marginTop="10dp"
  3. android:layout_width="fill_parent"
  4. android:layout_height="wrap_content"
  5. android:text="My Compound Button"
  6. android:drawableRight="@drawable/my_drawable" android:padding="5dp" />

但有时候,我们或许在一个<Linearlayout>中设置<TextView>   <ImageView>另有他用。一个很好的修改方法就是将<Linearlayout>修改为<RelativeLayout>布局,其次对于 android:drawableRight属性不可以使用,否则将会抛出另一个异常:Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path),因为这个属性对象是drawable。

下面是一个示例:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent">
  5. <ImageView
  6. android:id="@+id/image"
  7. android:contentDescription="@string/cs"
  8. android:layout_width="90dip"
  9. android:layout_height="90dip"
  10. />
  11. <TextView
  12. android:id="@+id/title"
  13. android:layout_width="wrap_content"
  14. android:layout_height="wrap_content"
  15. android:layout_below="@id/image"/>
  16. </RelativeLayout>

5:Eclipse警告:Warning:ArrayList is a raw type. References to generic type ArrayList should be parameterized 解决方案超赞(暂未翻译),参见:http://www.cnblogs.com/killerlegend/p/3349663.html

6:textview cannot be cast to imageview........

可以尝试的解决方法:Project-->clean,然后重新启动一次程序。

7:

Android之 ListView 的setonItemSelectedListener()之item单元点击无效处理方法

可以考虑换成下面的解决方法:

  1. mListView.setOnItemClickListener(new OnItemClickListener()
  2. {
  3. @Override
  4. public void onItemClick(AdapterView<?> parent, View view, int position,long id)
  5. {
  6. Toast.makeText(getApplicationContext(),
  7. "当前所在行为:"+Long.toString(parent.getItemIdAtPosition(position)+1),
  8. Toast.LENGTH_SHORT).show();
  9. }
  10. });

模拟器的鼠标滚动时会触发setItemOnselected()事件,而真机使用的软件,应该用 setItemOnClick().即手指头点击屏幕所出发的事件。

8:Error:ScrollView can  host only one direct child.......

意思就是ScrollView中只能有一个直接子代,如果出现两个或者两个以上,那么久会出现错误。你将scrollview中的子代换成一个就解决问题了。

9:AlertDialog提示错误:android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

原因:在使用AlertDialog的时候,如下:

  1. Dialog dialog = new AlertDialog.Builder(context).
  2. setTitle("温馨提示").
  3. setIcon(R.drawable.image).
  4. setMessage("本应用目前仅支持xxx地区,谢谢您的支持!").create();
    dialog.show();

出错原因在于AlertDialog.Builder(context)中传入的参数context不正确,传入的context不能由getApplicationContext()获得,而必须是Activity的名字,如果你的Activity的类的名字是Home.java

那么你在传入context的时候,只需传入Home.this即可。

10:报错:

  1. android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

在Intent变量中声明FLAG_ACTIVITY_NEW_TASK

  1. Intent intent = new Intent();
  2. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);

Android little error records的更多相关文章

  1. android studio Error:java.lang.OutOfMemoryError: GC overhead limit exceeded

    android studio Error:java.lang.OutOfMemoryError: GC overhead limit exceeded 在app下的build.gradle中找到and ...

  2. android stack error message is Fail to start the plugin

    E: 08-26 16:34:11.934: E/AliSDK(32236): 错误编码 = 1002208-26 16:34:11.934: E/AliSDK(32236): 错误消息 = SDK  ...

  3. android studio error configuration with name default not found

    Android Studio报错: android studio error configuration with name default not found 在进行sync的时候,提示Error: ...

  4. [2015-06-10 20:53:50 - Android SDK] Error when loading the SDK:

    1.错误描述 [2015-06-10 20:53:50 - Android SDK] Error when loading the SDK: Error: Error parsing D:\Andro ...

  5. Android Build Error(1)

    Type 1 —— Build Path Problem : **.jar包文件缺失 1.在Android项目根目录下新建一个libs文件夹: 2.把你需要的导入的第三方Jar包复制进这个目录: 3. ...

  6. 打包Android:Error building Player: CommandInvokationFailure

    错误log Error building Player: CommandInvokationFailure: Unable to determine the tools version of the ...

  7. android学习——error opening trace file: No such file or directory (2)

    1.疑惑: 程序运行起来的时候日志总是显示下面这个错误,但是不影响程序的正常进行,我是用真机来测试的,android4.4.4(API17). 02-11 14:55:03.629 15525-155 ...

  8. 关于 Android项目“error: Apostrophe not preceded by \ (”的解决方法

    用Eclipse环境开发Android项目,如果编译时控制台报出“error: Apostrophe not preceded by \ (”这种错误,那么多半是因为项目中的一个strings.xml ...

  9. [转]如何解决:Android中 Error generating final archive: Debug Certificate expired on 10/09/18 16:30 的错误

    本文转自:http://www.cnblogs.com/yyangblog/archive/2011/01/07/1929657.html 问题概述: 在导入一个app后提示如下错误: “Error ...

随机推荐

  1. 【Mood-11】值得学习的国内外Android开发者信息

    国内 Android 开发者信息: 昵称 GitHub 博客 介绍 罗升阳   Luoshengyang@csdn Android 源码分析 邓凡平   innost@csdn 阿拉神农 魏祝林   ...

  2. 使用手机模拟器与android操作系统

    创建手机模拟器: 1. 点击Eclipse中新增的按钮,打开"Android Virtual Device Manager"(不同版本的ADT可能打开路径不同),如下图: 2. 点 ...

  3. 《UNIX环境高级编程》学习心得 四 文件I/O(一)

    这里说的文件I/O是相对标准I/O来说的.主要介绍在UNIX系统中常用的五个文件I/O函数:open.read.write.lseek.以及close. 一.open和opennat #include ...

  4. CF Soldier and Cards (模拟)

    Soldier and Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  5. codeforces 677D D. Vanya and Treasure(二维线段树)

    题目链接: D. Vanya and Treasure time limit per test 1.5 seconds memory limit per test 256 megabytes inpu ...

  6. jsonp跨越请求百度搜索api 实现下拉列表提示

    题目来源: 最近在做百度IFE前端技术学院的题,然后有一题就是模拟百度搜索智能提示.题目是开源的,稍后给出地址. 因为博主没学过后端啊,欲哭无泪,所以不能实现后端模糊搜索,那如果前端ajax纯粹请求一 ...

  7. Android之图片滑动与显示

    先在Transitions中插入ImageSwitcher package com.example.Galleryphotoshow; import com.example.Galleryphotos ...

  8. Js中把JSON字符串转换为JSON对象(eval()、new Function())

    在JS中将JSON的字符串解析成JSON数据格式,一般有两种方式: 1.一种为使用eval()函数. 2. 使用Function对象来进行返回解析. 第一种解析方式:使用eval函数来解析,并且使用j ...

  9. 《Cocos2d-x实战 C++卷》上线了-源码-样章-感谢大家的支持

    <Cocos2d-x实战 C++卷>上线了 感谢大家一直以来的支持! 全面介绍Cocos开发技巧,采用Cocos2d-x3.2版本,并且详细介绍跨平台移植已经多平台发布细节. · 各大商店 ...

  10. C#中数组、ArrayList和List<T>三者的发展历程

    在C#中数组,ArrayList,List使我们用的最多的类型之一.他们共同的作用都是能够存储一组对象. 那么问题来了: (1)为什么要有三个一样作用的东西呢?他们都很完美吗? (2)谁先出生,又是因 ...