Android中ListView的item为EditText,点击EditText出现键盘但马上键盘就退出了 本帖最后由 u010414893 于 2014-10-23 17:17:30 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 估计是焦点被抢走了。你把setOnFocusChangeListener那行代码注释掉试试。 少了几个.xml文件,现贴出如下:1.res/drawable/dialog_background.xml<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item><shape> <padding android:bottom="4dip" android:left="4dip" android:right="4dip" android:top="4dip" /> <solid android:color="#FF00FF" /> <stroke android:width="1.0dip" android:color="#ffcccccc" /> <corners android:radius="6dp"/> </shape></item></selector>2.res/drawable/dialog_title_background.xml<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item><shape> <solid android:color="#888900" /> <stroke android:width="1.0dip" android:color="#ffcccccc" /> <corners android:topRightRadius="6dp" android:topLeftRadius="6dp" /> </shape></item></selector>3.res/layout/dialog_style.xml<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <RelativeLayout android:layout_width="match_parent" android:gravity="center" android:background="@drawable/dialog_title_background" android:layout_height="wrap_content" > <TextView android:layout_alignParentLeft="true" android:id="@+id/dialog_title" android:text="@string/dialog_title_fgla" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:layout_alignParentRight="true" android:id="@+id/dialog_close" android:text="@string/dialog_title_fgla_close" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </RelativeLayout> <LinearLayout android:layout_marginTop="8dp" android:layout_marginBottom="8dp" android:gravity="center_horizontal" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:text="@string/dialog_msg_fgla_1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:text="@string/dialog_msg_fgla_2" android:id="@+id/dialog_content" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> <LinearLayout android:layout_marginTop="8dp" android:layout_marginBottom="8dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal" > <Button android:background="@drawable/dialog_background" android:id="@+id/dialog_confirm" android:text="@string/dialog_submit_fgla" android:layout_width="wrap_content" android:layout_height="30dp" /> </LinearLayout></LinearLayout>4.res/values/styles.xml<resources><style name="MyDialog" parent="@android:Theme.Dialog"> <item name="android:windowFrame">@null</item> <item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@drawable/dialog_background</item> <item name="android:windowIsFloating">true</item> <item name="android:windowContentOverlay">@null</item> </style></resources>5.res/values/string.xml<?xml version="1.0" encoding="utf-8"?><resources><!-- FreeGiftListAdapter对话框 --> <string name="dialog_title_fgla">温馨提示</string> <string name="dialog_title_fgla_close">关闭</string> <string name="dialog_msg_fgla_1">很抱歉,您还没登录或者超时,请先登录。</string> <string name="dialog_msg_fgla_2">请先登录 | 注册</string> <string name="dialog_submit_fgla">确认</string></resources> 我是提问者http://vdisk.weibo.com/s/FDYvnsW1WJLol代码可以在这里下载! 我从你给的网站下了代码 ,直接导入eclipse中出现的一些错误。你看看截了些图这样我就表示处理不好了,如果能正常运行你的项目,我才可能帮你解决出来 你有没有把appcompat_v7_3这个文件作为工程的Library?麻烦麻烦帮帮看一下了。 试了半天还是没有给你弄出来 ,但是能得到一个结论。就是连续点击同一个EditText两次以上就能正常输入了。我再试试别的方法 这个问题好难啊,没有人遇到过吗?我感觉我的需求也不是很傻逼啊。阶段结论:应该是键盘出现的时候,重画了布局,所以又使EditText失去焦点了。 根据上面的朋友说的需要点击2次就可以输入的话我提出的意,LZ你试下看看LZ你使用OnFocusChangeListenerImpl监听事件是有需求吗你改为用setOnClickListener与setOnTouchListener监听事件2个都进行监听 谢谢支持啊!<activity android:name="com.example.mytest1.MainActivity" android:label="@string/app_name" android:windowSoftInputMode="adjustNothing" >在这里添加android:windowSoftInputMode="adjustNothing" 属性,键盘在弹出的时候你的adapter进行了刷新。我现在只能找到这种解决办法。 谢谢支持啊!android:windowSoftInputMode="adjustPan"这个属性完美的解决了! 你试试! 我试过你给的的这些属性设置了,仍旧不行,问一下 你这个属性石设置给EditText还是ListView啊?? 我试过你给的的这些属性设置了,仍旧不行,问一下 你这个属性石设置给EditText还是ListView啊??在AndroidManifest.xml中设置activity的属性时加这个 十分感谢,在AndroidManifest.xml中设置activity的属性时加android:windowSoftInputMode="adjustPan"。果然就行了 十分感谢,在AndroidManifest.xml中设置activity的属性时加android:windowSoftInputMode="adjustPan"。果然就行了结贴啊 第三方播放器的来电不停止问题、 Android应用安装覆盖问题 求助,Android图片上传,如何获取流数据传输进度? 短信监听 求助,android虚拟机运行时显示以下信息: ubuntu 11安装android ADT失败,求解!!!! 是变量作用域不同还是变量类型不同不能比较?小白求教为什么if判断总是false 我有几个Android相关的问题,大家看看会不会啊 进程通信 如何通过蓝牙打印图片? Facebook SDK里 如何调用注销 方法 Android实现扫描一段手机号码得到手机号码
你把setOnFocusChangeListener那行代码注释掉试试。
1.res/drawable/dialog_background.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item><shape>
<padding android:bottom="4dip" android:left="4dip" android:right="4dip" android:top="4dip" />
<solid android:color="#FF00FF" /> <stroke android:width="1.0dip" android:color="#ffcccccc" /> <corners android:radius="6dp"/>
</shape></item></selector>
2.res/drawable/dialog_title_background.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item><shape>
<solid android:color="#888900" /> <stroke android:width="1.0dip" android:color="#ffcccccc" /> <corners android:topRightRadius="6dp" android:topLeftRadius="6dp" />
</shape></item></selector>
3.res/layout/dialog_style.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <RelativeLayout
android:layout_width="match_parent"
android:gravity="center"
android:background="@drawable/dialog_title_background"
android:layout_height="wrap_content" > <TextView
android:layout_alignParentLeft="true"
android:id="@+id/dialog_title"
android:text="@string/dialog_title_fgla"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_alignParentRight="true"
android:id="@+id/dialog_close"
android:text="@string/dialog_title_fgla_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<LinearLayout
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:text="@string/dialog_msg_fgla_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:text="@string/dialog_msg_fgla_2"
android:id="@+id/dialog_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" > <Button
android:background="@drawable/dialog_background"
android:id="@+id/dialog_confirm"
android:text="@string/dialog_submit_fgla"
android:layout_width="wrap_content"
android:layout_height="30dp" />
</LinearLayout></LinearLayout>4.res/values/styles.xml
<resources>
<style name="MyDialog" parent="@android:Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/dialog_background</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
</resources>
5.res/values/string.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- FreeGiftListAdapter对话框 -->
<string name="dialog_title_fgla">温馨提示</string>
<string name="dialog_title_fgla_close">关闭</string>
<string name="dialog_msg_fgla_1">很抱歉,您还没登录或者超时,请先登录。</string>
<string name="dialog_msg_fgla_2">请先登录 | 注册</string>
<string name="dialog_submit_fgla">确认</string>
</resources>
http://vdisk.weibo.com/s/FDYvnsW1WJLol
代码可以在这里下载!
麻烦麻烦帮帮看一下了。
阶段结论:应该是键盘出现的时候,重画了布局,所以又使EditText失去焦点了。
我提出的意,LZ你试下看看
LZ你使用OnFocusChangeListenerImpl监听事件是有需求吗
你改为用setOnClickListener与setOnTouchListener监听事件2个都进行监听
android:name="com.example.mytest1.MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustNothing" >在这里添加android:windowSoftInputMode="adjustNothing" 属性,键盘在弹出的时候你的adapter进行了刷新。我现在只能找到这种解决办法。
我试过你给的的这些属性设置了,仍旧不行,问一下 你这个属性石设置给EditText还是ListView啊??
我试过你给的的这些属性设置了,仍旧不行,问一下 你这个属性石设置给EditText还是ListView啊??在AndroidManifest.xml中设置activity的属性时加这个