Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用软键盘更改Android中的按钮文本?_Android - Fatal编程技术网

如何使用软键盘更改Android中的按钮文本?

如何使用软键盘更改Android中的按钮文本?,android,Android,如何使用软键盘在按钮中输入文本。因此,按下按钮,软键盘将打开并由用户输入文本 public static void showKeyboard(View view) { InputMethodManager mgr = (InputMethodManager)myContext.getSystemService(Context.INPUT_METHOD_SERVICE); mgr.showSoftInput(view, InputMethodManager.SHOW_IMPL

如何使用软键盘在按钮中输入文本。因此,按下按钮,软键盘将打开并由用户输入文本

public static void showKeyboard(View view)

{

    InputMethodManager mgr = (InputMethodManager)myContext.getSystemService(Context.INPUT_METHOD_SERVICE);

    mgr.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);

    ((InputMethodManager)myContext.getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(view, 0);

}

此代码用于打开软键盘。你可以把这个放在你的按钮上。但我不确定是否要在按钮上键入内容。这是我第一次遇到。为什么不使用editText?请尝试使用editText的样式类型按钮。请参阅下面的XML代码

<EditText
            android:id="@+id/buttonedittext"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"                
            android:text="test"
            style="@android:style/Widget.Button" />

我显示像按钮,也当你们点击它显示软键盘,你们可以键入任何你们想要的


希望对您有用:)

根据客户要求,需要在按钮中输入文本。不使用编辑文本。