Recent Posts
Recent Comments
Link
«   2025/10   »
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
Archives
Today
Total
관리 메뉴

에이치의 모바일 앱 개발

keypad setting version 1.0.1 본문

Android/Android 개발 소스

keypad setting version 1.0.1

로이누리 2017. 12. 23. 01:44

토글소프트 인풋의 경우..

    키보드를 무조건 사라지게 하는게 아니라 현재 상태의 반대로 만든다.(예로 무조건 사라지게 하고 싶을 때 사용하면 된다.)


----------------------------xml 코드----------------------------
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="text"


android:imeOptions="normal" /> <!--특별한 의미 없음-->

android:imeOptions="actionUnspecified" /> <!--특별한 의미 없음-->

android:imeOptions="actionNone" /> <!--특별한 의미 없음-->

android:imeOptions="actionGo" /> <!--'이동'의 의미 (: 웹 브라우져에서 사용)--><

android:imeOptions="actionSearch" /> <!--'검색'의 의미 (: 네이버 검색창)-->

android:imeOptions="actionSend" /> <!--'보내기'의 의미 (: 메세지 작성시 사용)-->

android:imeOptions="actionNext" /> <!--'다음'의 의미 (: 회원가입시 다음 필드로 이동시)-->

android:imeOptions="actionDone" /> <!--'완료'의 의미 (: 정보 입력창)-->

android:imeOptions="actionPrevious" /> <!--'이전'의 의미 (: 회원가입시 이전 필드로 이동시) - API11부터 가능-->



----------------------------자바 코드----------------------------


public class MainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

EditText editText = new EditText(this);
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_NONE) {// 특별한 의미 없음
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {// 특별한 의미 없음
if (actionId == EditorInfo.IME_ACTION_GO) {// '이동'의 의미 (: 웹 브라우져에서 사용)
if (actionId == EditorInfo.IME_ACTION_SEARCH) {// '검색'의 의미 (: 네이버 검색창)
if (actionId == EditorInfo.IME_ACTION_SEND) {// '보내기'의 의미 (: 메세지 작성시 사용)
if (actionId == EditorInfo.IME_ACTION_NEXT) {// '다음'의 의미 (: 회원가입시 다음 필드로 이동시)
if (actionId == EditorInfo.IME_ACTION_DONE) {// '완료'의 의미 (: 정보 입력창)
if (actionId == EditorInfo.IME_ACTION_PREVIOUS) { // '이전'의 의미 (: 회원가입시 이전 필드로 이동시) - API11부터 가능
}}}}}}}
return true;
}
return false;
}
})
;
}
}


//한 클래스 내
setupUI(findViewById(R.id.activity_main));
}
public void hideSoftKeyboard(Activity activity) {
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
}

public void setupUI(View view) {
//Set up touch listener for non-text box views to hide keyboard.
if(!(view instanceof EditText)) {
view.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
hideSoftKeyboard(MainActivity.this);
return false;
}
});
}

//If a layout container, iterate over children and seed recursion.
if (view instanceof ViewGroup) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
View innerView = ((ViewGroup) view).getChildAt(i);
setupUI(innerView);
}
}
}
//다른 클래스
public class Keyboard {
public static void hideSoftKeyboard(Activity activity) {
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
}

public static void setupUI(View view, final Activity activity) {
//Set up touch listener for non-text box views to hide keyboard.
if(!(view instanceof EditText)) {
view.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
hideSoftKeyboard(activity);
return false;
}
});
}

//If a layout container, iterate over children and seed recursion.
if (view instanceof ViewGroup) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
View innerView = ((ViewGroup) view).getChildAt(i);
setupUI(innerView, activity);
}
}
}
}

 

 

Comments