0

如何自定义在 EditTextView 的 IME 操作按钮中显示的文本。我尝试使用 setImeActionLabel 但它不起作用。

public class TestIMEActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LinearLayout layout = new LinearLayout(this);
        layout.setOrientation(LinearLayout.VERTICAL);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
        final EditText ed1 = new EditText(this);
        ed1.setSingleLine(true);
        ed1.setImeActionLabel("test", 0);
        layout.addView(ed1, params);
        setContentView(layout);
    }
}
4

1 回答 1

0

我试图动态设置它。尝试在您的 xml 上设置它:

android:imeActionLabel="@string/myCustomActionLabel"

它对我有用。

请注意,您的文本仅在横向模式下可见。

于 2013-01-07T21:04:36.643 回答