안드로이드 개발 질문/답변
(글 수 45,052)
지금까지 찾아본 바로는. SurfaceView에서 일반적인 방법으로는 가상키보드가 나오지 않는것 같습니다.
그래서. 찾아낸 해결책은
1 - Activity에서 SurfaceView 를 등록(로딩) 하고, 필요한 EditText를 함께 넣어서, (초기에 invisible 세팅)
필요할때에, EditText를 활성화 시켜(visible), 보여주는 방법 (JetBoy 샘플) 인데요.
Q. 정령 SurfaceView 에서, 바로 가상키보드를 꺼낼수 없는건지요??
SurfaceView의 특정 위치를 터치하면, 가상키보드가 나오고, 키보드를 치면, SurfaceView의 특정 위치에
해당 문자를 찍고 싶은데... 아무리 구글링과, 국내 사이트를 다 뒤져봐도, 관련 글을 찾지 못했습니다.
(비슷한 내용은 있으나,, 정확한 내용은 없네요..)
위에 1번을 지금 구현중이지만 (아직 출력은 못해봤습니다), Activity 안의 특유의 윈도우 스타일의 어색한 컨트롤을 보자니..
마음이 편치가 않네요.. (윈도우의 DirectX 상에서, MFC 입력 컨트롤을 강제로 가져다 쓰는느낌..)
키보드 전문가분들의 답변을 학수고대합니다..
※ 공지사항을 다 읽었음 (처음 질문하네요..)
2010.08.16 14:52:11
///////////////////
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
imm.showSoftInput(eText_w, InputMethodManager.SHOW_FORCED);
imm.showSoftInputFromInputMethod (eText_w.getApplicationWindowToken(),InputMethodManager.SHOW_FORCED);
///////////////////
이런식으로 키보드를 특정화면으로 전환시 강제로 나오게 할수 있습니다.
단, Handler에서 처리해야합니다.
2010.08.19 10:29:12
@Override
protected Dialog onCreateDialog(int id) {
try {
switch(id) {
case SET_CASTLE_NAME:
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.new_castle, null);
final EditText ed = (EditText) textEntryView.findViewById(R.id.username_edit);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInputFromWindow(ed.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_NOT_ALWAYS);
Dialog dlg = new AlertDialog.Builder(LordOfD.this)
.setIcon(R.drawable.icon)
.setTitle("new castle")
.setView(textEntryView)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String strText = ed.getText().toString();
SkyDebug.print ("new castle name : " + strText);
Game.getIntance().setNewCastleName (strText);
game.getIntance().getInputView().setText(strText, 0xFF838178, 11, LTextView.AL_CENTER);
/* User clicked OK so do some stuff */
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked cancel so do some stuff */
}
})
.create();
return dlg;
}
}catch (Exception e) { }
return null;
}
전 그냥 이렇게 해결했습니다. 입력받은 데이타를 저장하고, 그것을 읽어 뿌려주는걸로. 할수 없죠 머 ㅎㅎ
2010.08.19 10:33:50
물론 xml을 하나 만들었습니다. (input 받기위해)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/username_view"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="castle name :"/>
<EditText android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:capitalize="none"
android:singleLine="false"
android:gravity="fill_horizontal"
android:id="@+id/username_edit"
android:layout_width="120dip"
android:layout_height="35dip"/>
</LinearLayout>