Editext 设置action

Editext 设置action

<EditText
            android:id="@+id/team_list_search"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/team_list_searchbar"
            android:gravity="center_vertical|left"
            android:hint="请输入"
            android:paddingLeft="35dp"
            android:paddingRight="30dp"
            android:singleLine="true"
            android:textColor="#666666"
            android:imeOptions="actionSearch"
             />
team_list_search.setOnEditorActionListener(new EditText.OnEditorActionListener() {
			@Override
			public boolean onEditorAction(TextView v, int actionId,
					KeyEvent event) {
				if (actionId == EditorInfo.IME_ACTION_SEARCH) {
					// 执行搜索功能
					if (TextUtils.isEmpty(team_list_search.getText()))
						return true;
					try {
						loadFriend();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				return false;
			}
		});

 

你可能感兴趣的:(Editext 设置action)