티스토리 뷰
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 |