티스토리 뷰

android

imeOptions 사용

구름나드리 2018. 10. 25. 17:12



imeOptions 사용




<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:paddingTop="200dp"
tools:context="com.codinginflow.imeoptionsexample.MainActivity">

<EditText
android:id="@+id/edit_text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username"
android:inputType="text" />

<EditText
android:id="@+id/edit_text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:imeOptions="actionSend"
android:inputType="textPassword" />

</LinearLayout>





public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

EditText editText1 = findViewById(R.id.edit_text1);
EditText editText2 = findViewById(R.id.edit_text2);
editText1.setOnEditorActionListener(editorListener);
editText2.setOnEditorActionListener(editorListener);
}

private TextView.OnEditorActionListener editorListener = new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
switch (actionId) {
case EditorInfo.IME_ACTION_NEXT:
Toast.makeText(MainActivity.this, "Next", Toast.LENGTH_SHORT).show();
break;
case EditorInfo.IME_ACTION_SEND:
Toast.makeText(MainActivity.this, "Send", Toast.LENGTH_SHORT).show();
break;
}
return false;
}
};
}



'android' 카테고리의 다른 글

EasyPermissions  (0) 2019.01.05
RecyclerView add,remove,delete  (0) 2018.12.03
HashMap 사용방법  (0) 2018.10.25
Custom AutoCompleteTextView  (0) 2018.10.23
spannable string  (0) 2018.10.23
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/12   »
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 31
글 보관함