android 输入框失去焦点,AutoCompleteTextView默认首次失去焦点

简介

android中常用于在输入框中输入内容后自动提示,这种效果就可以使用AutoCompleteTextView来实现,也是和EditText的区别。

特点

默认情况下直接进入其所在的页面后,获取焦点会直接弹出软键盘,这种效果在开发中可能体验不是很好,之前项目中需要的效果是,只有当用户点击了输入框后,才让软键盘弹出,这种效果肯能会比较好。

具体实现

只需要在根布局添加 android:focusable="true"、android:focusableInTouchMode="true"两条语句即可。

自己之前代码如下

1.

2. android:layout_width="match_parent"

3. android:layout_height="wrap_content"

4. android:layout_marginTop="5dp"

5. android:focusable="true"

6. android:focusableInTouchMode="true"

7. android:orientation="horizontal" >

8.

9.

10. android:id="@+id/tv_poi_input"

11. style="@style/common_text_style"

12. android:layout_width="0dp"

13. android:layout_height="wrap_content"

14. android:layout_gravity="center_vertical"

15. android:layout_weight="1"

16. android:background="@drawable/poi_search"

17. android:hint="@string/poi_input"

18. android:paddingLeft="10dp"/>

19.

20.

21. android:id="@+id/tv_search"

22. style="@style/common_text_style"

23. android:layout_width="wrap_content"

24. android:layout_height="wrap_content"

25. android:background="@drawable/btn_white_selector"

26. android:gravity="center"

27. android:text="@string/search" />

28.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值