【Android】Android部分问题记录
1.EditText不显示光标
开发的时候遇到有部分手机,小米系列以及华为部分手机不显示光标。
设置EditText属性
android:textCursorDrawable="@null"
android:cursorVisible="true"
可参考,http://stackoverflow.com/questions/15093758/edittext-cursor-is-invisible-in-android-4-0第一个回答。
附上我自己封装的一个方法
private final static String TAG = "EditTextCompat";
/**
* 设置光标可见 <br/>
* 此处为了解决部分手机(如小米、华为)无法显示光标的问题,由于编译环境为2.3,导致部分函数无法调用,此处使用反射调用<br/>
*/
public static void setCursorVisible(EditText editText, Context context) {
editText.setCursorVisible(true);
// sdk
// 对应关系表,见http://developer.android.com/guide/topics/manifest/uses-sdk-element.html
if (android.os.Build.VERSION.SDK_INT >= 12) {// Android 3.1.x API12
// HONEYCOMB_MR1
String filedNameString = "mCursorDrawableRes";
// mCursorDrawableRes
Class<? extends EditText> editTextClass = editText.getClass();
Class<? extends TextView> textViewClass = null;
if (editTextClass != null) {
textViewClass = (Class<? extends TextView>) editTextClass
.getSuperclass();
}
if (textViewClass != null) {
Field mCursorDrawableField = null;
try {
mCursorDrawableField = textViewClass
.getDeclaredField(filedNameString);
} catch (NoSuchFieldException e) {
// TODO Auto-generated catch block
Log.i(TAG, "NoSuchFieldException");
e.printStackTrace();
}
if (mCursorDrawableField != null) {
mCursorDrawableField.setAccessible(true);
try {
mCursorDrawableField.set(editText, 0);
} catch (IllegalArgumentException e) {
Log.i(TAG, "IllegalArgumentException");
e.printStackTrace();
} catch (NotFoundException e) {
Log.i(TAG, "NotFoundException");
e.printStackTrace();
} catch (IllegalAccessException e) {
Log.i(TAG, "IllegalAccessException");
e.printStackTrace();
}
}
}
}
}
}
2.AutoCompleteTextView在部分手机(如联想a860e)显示黑条。
见图

解决方案:在themes.xml设置一个主题,设置它的android:dropDownListViewStyle属性。
<style name="search_theme" parent="android:style/Theme.NoTitleBar">
<item name="android:dropDownListViewStyle">@style/widget_dropdownlistview</item>
</style>
在styles.xml中定义下面字段。
<style name="widget_dropdownlistview" parent="android:style/Widget.Holo.ListView.DropDown">
<item name="android:scrollbars">none</item>
<item name="android:divider">@color/white</item>
</style>
对需要用到AutoCompleteTextView的Activity设置主题(AndroidManifest.xml中设置)。
然后样式就OK了。
如图

可参考http://www.apkbus.com/android-126131-1-1.html
3.Dialog在部分手机上显示黑条
设置
<item name="android:windowContentOverlay">@null</item>
可参考。http://www.cnblogs.com/kaima/archive/2011/07/29/2121457.html
【Android】Android部分问题记录的更多相关文章
- android布局常用属性记录
android布局常用属性记录 http://blog.csdn.net/xn4545945/article/details/7717086这里有一部分别人总结的其余的: align:对齐 par ...
- android studio 使用问题记录
android studio 使用问题记录 下载地址:FQ或园子内好心人提供的国内地址: http://www.cnblogs.com/bjzhanghao/archive/2012/11/14/an ...
- Android中的路径记录
Android中的路径记录 | RobinBlog 导航 导航 博客 分类 标签 友链 关于 搜索 Environment.getDataDirectory().getPath()=/dataEnvi ...
- Android遇到的错误记录
解决小米手机无法收到开机广播的问题 http://blog.csdn.net/ksr12333/article/details/16116627 怎样在Android Studio中打开DDMS窗口? ...
- Android 手机影音 开发过程记录(六)
前一篇已经将音乐播放及切换的相关逻辑弄好了,今天主要理一下剩余的部分,包含: 1. 自己定义通知栏的布局及逻辑处理 2. 滚动歌词的绘制 3. 歌词解析 效果图 通知栏 自己定义布局: <?xm ...
- Android Adapter的一些记录
一.摘要 An Adapter object acts as a bridge between an AdapterView and the underlying data for that view ...
- 图解Android - Android GUI 系统 (1) - 概论
Android的GUI系统是Android最重要也最复杂的系统之一.它包括以下部分: 窗口和图形系统 - Window and View Manager System. 显示合成系统 - Surfac ...
- Android] Android XML解析学习——方式比较
[Android] Android XML解析学习——方式比较 (ZT) 分类: 嵌入式 (From:http://blog.csdn.net/ichliebephone/article/deta ...
- Stack Overflow 排错翻译 - Closing AlertDialog.Builder in Android -Android环境中关闭AlertDialog.Builder
Stack Overflow 排错翻译 - Closing AlertDialog.Builder in Android -Android环境中关闭AlertDialog.Builder 转自:ht ...
- [Android]Android端ORM框架——RapidORM(v2.1)
以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/6020412.html [Android]Android端ORM ...
随机推荐
- cocos2dx 初探 - VS2012 HELLOWORLD
最近决定用cocos2dx 来做些试验性的东西,先装了个vs2012 再从网上下了cocos2dx-2.1.4就开工了. 仅是Windows 桌面调试还是很简单的. 上面三个项目源: Hellocpp ...
- leetcode problem 42 -- Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...
- Python3 多进程和多线程
Unix/Linux操作系统提供了一个fork()系统调用,它非常特殊.普通的函数调用,调用一次,返回一次,但是fork()调用一次,返回两次,因为操作系统自动把当前进程(称为父进程)复制了一份(称为 ...
- CSS弹性盒模型 box-flex
目前没有浏览器支持boc-flex属性. Firefox支持代替的-moz-box-flex属性 Safari.Opera以及Chrome支持替代的-webkit-box-flex属性 box-fle ...
- Html盒子模型学习总结
Html的盒子模型 1.总的来说Html元素可以分为两类:即块状元素和行内元素. 2.块状元素(Block)类型的元素可以设置Width和Height值属性,而行内(Inline)类型无效. 3.浏览 ...
- 判断浏览器是否支持某个css3属性的javascript方法
判断浏览器是否支持css3某个属性的方法: /** * 判断浏览器是否支持某一个CSS3属性 * @param {String} 属性名称 * @return {Boolean} true/false ...
- Linux 源码的安装 3个步骤
http://www.oseye.net/question/96 源码的安装一般由3个步骤组成:配置(configure).编译(make).安装(make install). Configure是一 ...
- PHPCMS二次开发教程(转)
转自:http://www.cnblogs.com/semcoding/p/3347600.html PHPCMS V9 结构设计 根目录 |–api 结构文件目录 |–caches 缓存文件目录 ...
- FolderBrowserDialog组件选择文件夹
1.选择路径 this.folderBrowserDialog1.ShowDialog(); if (this.folderBrowserDialog1.ShowDialog() == DialogR ...
- sbrk and coreleft
一.sbrk 函数来源:TC2.0.Linux 函数名: sbrk 功 能: 增加程序可用数据段空间,增加大小由参数 incr决定 . 返回值:函数调用成功返回一指针,指向新的内存空间.函数调用失败则 ...