-
打开 lint warnings view (Window > Show View > Other > android > Lint Warnings) 然后修改 proguard.cfg
-
把有错行的 "keepclasseswithmembernames" 改为 "keepclasseswithmembers"
-
重编绎 (点Lint Warnings view里的refresh灯泡左边的按钮)
-
如果还报错,就接着改其它行。
String temp = "[{\"aa\":\"1\",\"bb\":\"2\"},{\"aa\":\"3\",\"bb\":\"4\"},{\"aa\":\"5\",\"bb\":\"6\"}]";
List<Map<String, Object>> lm = Test.getList(temp);
for(int i=0;i<lm.size();i++){
System.out.println(lm.get(i).get("aa"));
System.out.println(lm.get(i).get("bb"));
}
6、空间居中
通过设置 android:gravity="center" 来让 EditText 中的文字在 EditText 组件中居中显示;同时我们设置 EditText 的 android:layout_gravity="right" 来让 EditText 组件在 LinearLayout 中居中显
7、让控件在一行
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
if (name != null && !name.equals("")) {
//do something
}
或者
if (!"".equals(name)) {//将""写在前头,这样,不管name是否为null,都不会出错。
//do something
}
9、Failed to install *.apk on device 'emulator-5554': timeout
- 错误提示:
Failed to install helloworld.apk on device 'emulator-5554': timeout
或者
the user data image is used
原因:
由于模拟器已经开启而没有关闭或者非法关闭引起的。
解决方法:
删除 C:\Documents and Settings\Administrator\.android\avd\对应版本.avd
下所有以.lock结尾的文件夹。
或者
Failed to install *.apk on device *:
timeout Launch canceled!
还有一种办法:
在window->preferences->Android->DDMS->ADB connection time out (ms):
14、Sqlite查询结果按照相关度排序
标题中同时出现" 数据库"和"Sql" >> 内容中同时出现"数据库"和"Sql" >> 标题中出现"数据库"或"Sql" >>内容中出现"数据库"或"Sql"
排序可以用:
Select Title,Content from Article where
Title like '%数据库%' and Title like '%Sql%'
union all
Select Title,Content from Article where
not (Title like '%数据库%' and Title like '%Sql%')
and Content like '%数据库%' and Content like '%Sql%'
union all
Select Title,Content from Article where
not (Title like '%数据库%' and Title like '%Sql%')
and not (Content like '%数据库%' and Content like '%Sql%')
and (Title like '%数据库%' or Title like '%Sql%')
union all
Select Title,Content from Article where
Title not like '%数据库%' and Title not like '%Sql%'
and not (Content like '%数据库%' and Content like '%Sql%')
and (Content like '%数据库%' or Content like '%Sql%')
<activity
android:name=".SendActivity">
<intent-filter>
<action android:name="android.intent.action.SEND"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<data android:mimeType="text/plain"></data>
</intent-filter>
</activity>
然后在SendActivity。class添加:
protected void onStart() {
super.onStart();
Intent txtIntent=getIntent();
String Lat,Lng; //39.452246,110.541718
String LL = txtIntent.getStringExtra(Intent.EXTRA_TEXT);
if (LL == null)
LL = "";
try {
if(!("".equals(LL))){
String[] LLL = LL.split(",");
Lat=LLL[0];
Lng=LLL[1];
Log.i("Lat/Lng",Lat+"/"+Lng);
med.setText(LL);
mTextView.setText(LL);
Toast.makeText(getApplicationContext(), "二维码方式获取经纬度:"+LL, 1);
}
} catch (Exception e) {
Log.i("118-login","二维码方式获取经纬度失败");
Toast.makeText(getApplicationContext(), "二维码方式获取经纬度失败"+e.getMessage(), 1);
}
// mTextView.setText(txt);
}
19、引用jar中资源文件的修改:用winrar打开并修改相关图片,比如图标(可改为透明的,不能删除)再压缩回去就行。
20、报错:java.lang.NoClassDefFoundError: com.baidu.mapapi.BMapManager
解决方案:
一、右击项目->properties->Java Build Path->Order and Export,在需要引用的包前面打勾。
二、Project->Clean...
问题解决,
21\很多人出现了java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{*****Activity}: java.lang.ClassNotFoundException: Didn't find class "*****Activity" on path: /data/app/*******.apk的错误,在android开发中,我也遇到了这个问题,纠结了两天,终于解决了,结合我自己加上网上的找到的,现提供给大家。
1。Manifest文件中注册的Activity的名称,有没有写错,包名有没有搞错,有些网友,可能只写一个类名,前面用点号代替,但是这个类不在默认的包内,所以报这个错,那么只要写上类的全名,即可。
2。有些android,需要一些第三方的包,直接将其引入,在以前是可以的,但是在最新的adt中不行,必须在程序中新建一个libs文件夹,将第三方的jar文件copy到libs文件夹中,才行,很多人因为这样才报错,特别是以前的项目,默认并没有这个libs文件夹,但是新版本的adt,默认就建了libs这个文件夹。
3。有一点也很重要,在Java Build Path面板下的Order and Export中,一定要把你引入的jar文件,勾上,否则,跟没引用一样,切记。
一般也就是以前的原因了,如果大家有看不明白的,或者有什么其他原因的,请跟我留言,共同分享,共同进步!
22\ android.os.NetworkOnMainThreadException异常如何解决在做android开发 大家也会经常莫名其妙遇到各种问题,今天遇到这个问题也很奇怪,项目一直采用的是android sdk2.2开发
上一个app没有出现如题的问题,但这个版本却出现了,后来在网上看有说添加代码
- <span style="font-size:18px;"> 详见StrictMode文档
- StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
- .detectDiskReads()
- .detectDiskWrites()
- .detectNetwork() // or .detectAll() for all detectable problems
- .penaltyLog()
- .build());
- StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
- .detectLeakedSqlLiteObjects()
- .detectLeakedClosableObjects()
- .penaltyLog()
- .penaltyDeath()
- .build());</span>
这样也可以解决问题,但sdk就不能采用2.2了
还有种解决办法就是在AndroidManifest.xml 里面进行配置
最近之所以出现这样问题是我在里面这样写的
- <span style="font-size:18px;"> <uses-sdk
- android:minSdkVersion="3"
- android:targetSdkVersion="14" /></span>
后来改为
- <span style="font-size:18px;"> <uses-sdk
- android:minSdkVersion="3"
- android:targetSdkVersion="8" /></span>
这样就可以了!
05-02 17:09:31.019: D/BMapApiEngine_v1_3_0(3703): BMapApiEngine_v1_3_0 library not found!
05-02 17:09:31.019: D/BMapApiEngine_v1_3_0(3703): Couldn't load BMapApiEngine_v1_3_0 from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.surfing.conference-
解决过程:
1、下载了一个BMapApiEngine_v1_3_0放在libs/armeabi文件夹下,在运行程序,报同样的错误;
解决办法:
1、在工程目录下新建一个jars文件夹,把libs文件夹下的所有jar包,拷贝到jars目录下;
2、在工程属性中,移除的jar文件,重新加入jars文件下的jar文件;
运行工程,问题解决。
Android如何将Activity以Dialog的形式显示 :
1、AndroidManifest.xml 文件中,申明 activity 的主题使用自定义对话框样式。
<activity android:name=".SensorGetValueActivity"
android:label="@string/activity_custom_dialog"
android:theme="@style/Theme.CustomDialog">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
2、res/values/styles.xml 样式文件中定义一个对话框主题样式,这里继承了 android:style/Theme.Dialog 主题,
并且窗口样式 android:windowBackground 引用了 @drawable/filled_box
<item name="android:windowBackground">@drawable/filled_box</item>
</style>
3、res/drawable/filled_box.xml 定义了 Shape 类型的 drawable(抽象的可画区域),最终是通过这个来实现新对话框的样式。
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#f0600000"/>
<stroke android:width="3dp" color="#ffff8080"/>
<corners android:radius="3dp" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>