gpt4 book ai didi

android - 未调用 setOnEditorActionListener

转载 作者:行者123 更新时间:2023-11-30 02:58:57 25 4
gpt4 key购买 nike

我更新了我的应用程序,但现在监听器不工作了。
我将此 Activity 用于类似的操作:
1. EditText (IP地址) & AutoCompleteTextView (子网掩码)
2. EditText(IP 地址)和 AutoCompleteTextView(主机数;无微调器)

此类扩展了 NavigationDrawerActivity,我将其与 Intent 一起使用以在这两个和其他两个之间切换。

按钮工作正常。

在创建我的主要 Activity 时

public void onCreate(Bundle savedInstanceState) {
//License and Google Analytics code removed

setContentView(R.layout.activity_main);
super.onCreate(savedInstanceState);
context=this;

calc_screenSize(); //for the padding in initialise_views

initialise_views(); //with findViewById
initialise_table(); //subnettable with 4 quads, among other code

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

btn_berechnen.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
standard_go(false, true);

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(et_input_IP.getWindowToken(), 0);
imm.hideSoftInputFromWindow(et_input_SNM.getWindowToken(), 0);
}
});

et_input_SNM.setOnEditorActionListener(new OnEditorActionListener() {//not called - why?
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
Log.d("actionId",actionId+"");
Log.d("actionId",EditorInfo.IME_ACTION_DONE+"");

if (actionId == EditorInfo.IME_ACTION_DONE) {
standard_go(false, true);

return true;
}

return false;
}
});

//license check code rmoved
}

activity_main.xml 和其他 activity_xxx.xml 包含:

<EditText
android:id="@+id/input_ipAdresse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignRight="@+id/Button_berechnen"
android:ellipsize="end"
android:ems="10"
android:gravity="right"
android:hint="@string/input_ipAdresse"
android:imeOptions="flagNoExtractUi"
android:inputType="phone"
android:paddingRight="@dimen/padding_small"
android:textSize="@dimen/fontsize_medium" >

<requestFocus android:layout_width="match_parent" />
</EditText>

<AutoCompleteTextView
android:id="@+id/input_snm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/input_ipAdresse"
android:ellipsize="end"
android:ems="10"
android:gravity="right"
android:imeActionLabel="@string/Button_berechnen"
android:imeOptions="actionDone|flagNoExtractUi"
android:inputType="phone"
android:paddingRight="@dimen/padding_small"
android:textSize="@dimen/fontsize_medium" />

最佳答案

完成:

et_input_SNM.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
Log.d("actionId","OnKeyListener: "+keyCode+" - "+KeyEvent.KEYCODE_ENTER);
if(keyCode == KeyEvent.KEYCODE_ENTER) {
standard_go(false, true);
return true;
}
return false;
}
});

关于android - 未调用 setOnEditorActionListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22845392/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com