4.03Android学习

一、今日学习

 今天是一和二

1、隐藏android中EditText自带的的下划线

1
2
android:background="@null"
或android:background="@/drawable/bg_edittext_norma.xml"

bg_edittext_norma.xml

1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="UTF-8"?>
    <!--商品描述的可编辑框-->
    <solid android:color="#FFFFFF" />
    <corners android:radius="10dip"/>
    <stroke
        android:width="1dip"
        android:color="#BDC7D8" />
</shape>
1
2
3
4
5
6
7
8
<EditText
       style="?android:attr/textViewStyle"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:background="@null"
       android:hint="输入用户名"
       android:paddingBottom="5dip"
       android:paddingTop="5dip" />

 

2、让软键盘出现搜索按钮

  • 核心代码块1:

这俩个一定要设置,要不然软键盘不会出现搜索

1
2
android:imeOptions="actionSearch"
android:singleLine="true"
  • 核心代码块2:

Activity或者Fragment 要实现TextView.OnEditorActionListener接口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public class DrugCatalogueInquiryFragment extends GeneralSocialFragment implements TextView.OnEditorActionListener {
 
 private ClearEditText etDrugName;
 
 etDrugName = xFindViewById(R.id.et_drug_name);
 etDrugName.setOnEditorActionListener(this);
 
  @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        doWhichOperation(actionId);
        return true;
    }
 
    private void doWhichOperation(int actionId) {
        switch (actionId) {
            case EditorInfo.IME_ACTION_SEARCH:
                //隐藏项目中弹框
                hideSoftInputMethod();
 
                //项目中个性化操作
                getEditTextValue();
                pageno = 1;
                getMedicineListInfoForApp(name,firstWord,type,level,pageno);
                break;
            default:
                break;
        }
    }

 

原文

二、问题

 暂无

三、明日计划

继续今天这一part

posted @ 2021-04-03 21:59  居酿圆子  阅读(31)  评论(0编辑  收藏  举报