Tôi đã có bố cục với hai phiên bản editexts. Tôi cần thiết lập tập trung thứ hai và có thể chỉnh sửa khi phím enter được nhấn vào phím đầu tiên. Tôi có mã để đặt tiêu điểm nhưng tôi không thể bắt đầu nhập khi chế độ lấy nét thứ hai được lấy nét.Đặt EditText tiếp theo tập trung và có thể chỉnh sửa trên KEY_DOWN
PS Tôi cũng cần edittext để có chiều cao chính xác một dòng mà không có khả năng tạo hàng bổ sung. Nó cũng hoạt động. PSS android đang 2.3
XML:
<EditText
android:id="@+id/email"
style="@style/profileLoginInput"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:hint="@string/email" android:ems="10" android:lines="1" android:maxLines="1" android:ellipsize="end">
<requestFocus />
</EditText>
<EditText
android:id="@+id/password"
style="@style/profileLoginInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:ems="10"
android:inputType="textPassword" android:hint="@string/password">
mã Java:
((EditText) findViewById(R.id.email)).setOnKeyListener(new OnKeyListener(){
@Override
public boolean onKey(View v, int keyCode, KeyEvent event)
{
if (event.getAction() == KeyEvent.ACTION_DOWN)
{
switch (keyCode)
{
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
((EditText) findViewById(R.id.password)).requestFocus();
return true;
default:
break;
}
}
return false;
}
});
-its a, android: nextFocusDown = "@ id/editText2", xóa '+' khỏi id. Và thử lại cho tôi biết mũ xảy ra .. – user370305
nó nói rằng nó không thể tìm thấy một nguồn tài nguyên - u có thể đăng một mã mẫu với các điều kiện tôi đã đề cập ở trên? – user1462299
Mã của bạn hoạt động tốt trong trường hợp của tôi .. – user370305