키 이벤트를 내 EditText's
에 수신하고 next
을 누를 때마다 EditText
의 텍스트를 내 데이터 개체에 저장하려고합니다. 물론Android onKey()가 호출되지 않습니다.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
savedInstanceState) {
v = inflater.inflate(R.layout.frag_userprofile_myinfo, container, false);
context = getActivity().getApplicationContext();
global = (eKeshGlobal) context;
pbWait = (ProgressBar) v.findViewById(R.id.pbWait);
bnDone = (Button) v.findViewById(R.id.bnDone);
rlBack = (RelativeLayout) v.findViewById(R.id.rlBack);
etFirstName = (EditText) v.findViewById(R.id.etFirstName);
etLastName = (EditText) v.findViewById(R.id.etLastName);
etAdress = (EditText) v.findViewById(R.id.etAdress);
etMobile = (EditText) v.findViewById(R.id.etMobile);
etDob = (EditText) v.findViewById(R.id.etDob);
etOib = (EditText) v.findViewById(R.id.etOib);
etFirstName.setOnKeyListener(this);
etLastName.setOnKeyListener(this);
etAdress.setOnKeyListener(this);
etMobile.setOnKeyListener(this);
etDob.setOnKeyListener(this);
etOib.setOnKeyListener(this);
return v;
}
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode ==
KeyEvent.KEYCODE_ENTER)) {
switch(v.getId()) {
case R.id.etFirstName:
user.setFirstName(etFirstName.getText().toString());
return true;
case R.id.etLastName:
user.setLastName(etLastName.getText().toString());
return true;
case R.id.etAdress:
user.setAddress(etAdress.getText().toString());
return true;
case R.id.etMobile:
user.setMobile(etMobile.getText().toString());
return true;
case R.id.etDob:
user.setDateOfBirth(Utils.formatDate(context,
etDob.getText().toString()));
return true;
case R.id.etOib:
user.setOib(etOib.getText().toString());
return true;
default:
return false;
}
}
return false;
}
내가 구현 한 청취자 : 내가 호출되지 왜 그럴수 OnKeyListener
하고 onKey()
방법을 구현 ... 여기 내 코드의
public class UserProfileMyInfo extends Fragment implements View.OnKeyListener
그리고 여기 샘플입니다 EditText
의 XML : 난 정말이 작품을 얻기 위해 아이디어의 부족 해요
<EditText
android:id="@+id/etLastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:ems="10"
android:hint="@string/my_profile_lastname"
android:imeOptions="actionNext"
android:inputType="text"
android:singleLine="true" />
, 내가 함께 tryed onKeyDown()
도 작동하지 않았다. .. 미리 감사드립니다!
내가 왜 안 보이는지 모르겠다. 작동하지 않는다고 생각하는 또 다른 이유가 없다고 확신 할 수 있습니까? onKey의 첫 번째 줄에 중단 점을 넣으면 충돌이 발생합니까? – Eluvatar