所以我的Oneplus 3t上有一个问题,即输入键创建了一个新行并且实际上没有动作,但在三星手机上它工作正常。这是EditText
plot(fitted(fit)[w!=0], rstudent(fit))
这就是我处理行动的方式
<EditText
android:id="@+id/section"
android:layout_width="230dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="30dp"
android:layout_toEndOf="@+id/nav_button"
android:layout_toRightOf="@+id/nav_button"
android:background="@android:color/transparent"
android:clickable="false"
android:ems="10"
android:focusable="false"
android:gravity="left"
android:inputType="textMultiLine|textNoSuggestions"
android:maxHeight="140dp"
android:scrollbars="vertical"
android:text="@string/section"
android:textColor="@color/textColor"
android:textSize="20sp" />
同样在像素2上的虚拟设备中,当我按下键盘上的回车键时,它会创建一个新行,但当我按下我自己键盘上的回车键时,它确实有效。
编辑:我通过将EditText更改为此
来修复它 mSearch.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
switch (i) {
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
unReadySeach(section, mSearch, search, mSearch.getText().toString(), mNavButton, backArrow);
gridView.setAdapter(new QuoteImageAdapater(getApplicationContext(), reader.getSearchData(mSearch.getText().toString()), section));
searched = true;
return true;
}
}
return false;
}
});
答案 0 :(得分:0)
尝试使用此解决方案,因为您使用过的解决方案,不保证软键。
第一个解决方案:
<EditText
android:id="@+id/search"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/search_hint"
android:inputType="text"
android:imeOptions="actionSend" />
EditText editText = (EditText) findViewById(R.id.search);
editText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_SEND) {
sendMessage();
handled = true;
}
return handled;
}
});
第二个解决方案
mSearch.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
// If the event is a key-down event on the "enter" button
if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
(keyCode == KeyEvent.KEYCODE_ENTER))
{
// Perform action on Enter key press
unReadySeach(section, mSearch, search, mSearch.getText().toString(), mNavButton, backArrow);
gridView.setAdapter(new QuoteImageAdapater(getApplicationContext(), reader.getSearchData(mSearch.getText().toString()), section));
searched = true;
return true;
}
return false;
}
});