相关疑难解决方法(0)

android如何为edittext设置隐藏键盘

在我的应用程序中,我有一个editText.如果我点击它然后它应该打开日期选择器对话框而不是键盘.它的开放日期是骑手,但随着键盘也随之而来.

(默认情况下键盘来自editText,但我不想要)我希望这个editText键盘不应该可见/应该被隐藏.

我怎样才能做到这一点?

我喜欢这个,

   private EditText editDate;
  editDate=(EditText)findViewById(R.id.editDate);

editDate.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(editDate.getWindowToken(), 0);

                 showDialog(DATE_DIALOG_ID);
            }
        });
Run Code Online (Sandbox Code Playgroud)

它不起作用.有什么办法吗?

谢谢

android datepicker

2
推荐指数
1
解决办法
4699
查看次数

在输入法服务中隐藏软键盘

我正在尝试从InputMethodService隐藏我的软键盘,并且无法正常工作。这是我在onFinishInput()方法中使用的代码:

InputMethodManager im = (InputMethodManager)
context.getSystemService(Context.INPUT_METHOD_SERVICE);
im.hideSoftInputFromWindow(mInputView.getWindowToken(), 0);
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

android android-input-method

2
推荐指数
1
解决办法
2800
查看次数

禁用软键盘

我有一个edittext在我的布局中,像这样:

//...    
<EditText
    android:id="@+id/editText_username"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="@string/string_username" >
</EditText>
//...
Run Code Online (Sandbox Code Playgroud)

当显示布局时,键盘会出现焦点edittext,但这恰好发生在ICS中......而且我不希望键盘自动出现,就像edittext单击时一样.

我怎样才能做到这一点?

keyboard android android-edittext

2
推荐指数
1
解决办法
3671
查看次数

2
推荐指数
2
解决办法
1万
查看次数

在android中隐藏虚拟键盘?

嗨,即使用户触摸editText字段,我也不想显示虚拟键盘.

android

1
推荐指数
1
解决办法
3328
查看次数

如何在android中隐藏软键盘

我正在使用我的应用程序中的编辑文本字段.当我点击它时出现软键盘.但是当我点击"完成"按钮(在软键盘上)时,它应该消失但它不会消失.我将输入类型设置为布局文件中的文本.我想按下按钮时隐藏软键盘.请帮忙.谢谢.

这是我的代码.

public class locupdate extends MapActivity implements OnDoubleTapListener{

    GeoPoint p,geoPoint;
    MapView SearchMap;
    List<Overlay> list;
    MapController map_controller;
    LocationManager locationManager;
    Location location,update_location ;
    MyLocationOverlay me;
    Button go_btn,done;
    String city;
    int cid;
    Double lat_update,lng_update;
    EditText location_entered;
    @Override
    public void onCreate(Bundle savedInstanceState){

        super.onCreate(savedInstanceState);
        setContentView(R.layout.bingmapupdate);
        go_btn=new Button(getApplicationContext());
        go_btn=(Button)findViewById(R.id.go_button);

        location_entered=(EditText)findViewById(R.id.enterLocationforSearch); 
        location_entered.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                location_entered.setText("");

            }
        });
        done=new Button(getApplicationContext());
        done=(Button)findViewById(R.id.button_locationUpdateDone);
        done.setEnabled(false);
        done.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
                SharedPreferences.Editor editor=preferences.edit();
                String memberid=preferences.getString("unique_userName", null);

                String …
Run Code Online (Sandbox Code Playgroud)

android hide android-softkeyboard android-edittext

1
推荐指数
1
解决办法
5132
查看次数

DrawerLayout的监听器和配置

由于谷歌文档谷歌的样本,我已经构建了一个导航抽屉.

现在我正在寻找一个解决方案,在右侧滑动关闭时隐藏键盘,因为在这张幻灯片中我有一个EditText,当我关闭菜单时,键盘仍然打开.

最后,当我打开菜单时,布局会覆盖主要内容.所以我想知道是否有一种简单的方法可以使主要内容跟随菜单的运动,Facebook就像?

keyboard android navigation-drawer drawerlayout

1
推荐指数
1
解决办法
5088
查看次数

当条形码扫描器读取条形码时,EditText焦点消失

我需要读取应用程序的条形码。我为此使用了触发条码扫描器。通过USB进行通讯。

如您所知,条形码扫描仪的工作原理类似于键盘。当设备读取条形码时,它将尝试将值写入具有焦点的输入。然后,用户按下触发器,条形码扫描器便会工作,直到成功读取条形码为止。然后,它进入待机模式。读取大量条形码的理想方法。

问题在于,用户按下触发器并读取条形码后,EditText的焦点消失了。焦点将随机转到同一布局中的另一个视图。当用户尝试再读取一个条形码时,该操作失败,因为没有关注相关的EditText。

我尝试了什么?

android:windowSoftInputMode="stateAlwaysVisible"
Run Code Online (Sandbox Code Playgroud)

将以上行添加到清单文件

android:focusable="true"
android:focusableInTouchMode="true"
Run Code Online (Sandbox Code Playgroud)

在xml端添加了以上几行。

 edtBarcode.setOnFocusChangeListener(new View.OnFocusChangeListener()
    {
        @Override
        public void onFocusChange(View v, boolean hasFocus)
        {
            if (!hasFocus)
            {
                //find the view that has focus and clear it.
                View current = getCurrentFocus();
                if (current != null)
                {
                   current.clearFocus();
                } 

                edtBarcode.requestFocus();
            }
        }
    });
Run Code Online (Sandbox Code Playgroud)

它检测EditText何时失去焦点。但是我不能把它分配回来。我确保EditText在触摸模式下可聚焦。

我该如何解决?

    handlerFocus = new Handler();
    final int delay = 1000; //milliseconds

    handlerFocus.postDelayed(new Runnable()
    {
        public void run()
        {
            edtBarcode.requestFocus();
            handlerFocus.postDelayed(this, delay);
        }
    }, delay);
Run Code Online (Sandbox Code Playgroud)

我知道这个解决方案不好。那么,如何在不打开键盘的情况下使焦点始终保持在同一EditText中呢?

android focus android-edittext

1
推荐指数
1
解决办法
1706
查看次数

按钮单击隐藏键盘

我有一个meme creator应用程序,我有两个文本字段和一个按钮,我想按下按钮来隐藏键盘,这可能吗?

android

0
推荐指数
1
解决办法
8805
查看次数

自定义对话框关闭后,在Android中隐藏软键盘

我遇到了一个editText的情况.当我在编辑文本中按添加时,我在列表中添加成员.何时添加(或不添加)我正在打开自定义对话框.

在我的活动中,当点击编辑文本中的添加按钮时,我有这个代码:

  customDialogTeamMember = new CustomDialogTeamMember(............);
  customDialogTeamMember.makeDialog();
  editText.getText().clear();
  editText.clearFocus();
  hideSoftKeyboard();
Run Code Online (Sandbox Code Playgroud)

我的hideSoftKeyboard()定义如下:

public void hideSoftKeyboard() {
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}
Run Code Online (Sandbox Code Playgroud)

此方法适用于应用程序的其他部分.但这里没有用!

自定义对话框打开.当我关闭它时,键盘保持在屏幕上.可能是什么问题呢?!

keyboard android customdialog android-edittext

0
推荐指数
1
解决办法
4044
查看次数

如何在片段中隐藏软键盘?

我想隐藏在android中的片段中的键盘.因为一旦它显示它仍然在所有片段中可见.我尝试这种方法

    public static void hideKeyboard(Context ctx) {
    InputMethodManager inputManager = (InputMethodManager) ctx
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    // check if no view has focus:
    View v = ((Activity) ctx).getCurrentFocus();
    if (v == null)
        return;

    inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
Run Code Online (Sandbox Code Playgroud)

并在按钮单击时调用此方法

signIn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
                hideKeyboard(ctx);
                login();


        }
    });
Run Code Online (Sandbox Code Playgroud)

但这会给出错误"java.lang.NullPointerException:尝试在空对象引用上调用虚方法'java.lang.Object android.content.Context.getSystemService(java.lang.String)'"

android android-fragments

-1
推荐指数
1
解决办法
1859
查看次数

输入文本后摆脱弹出键盘(软键盘?) - ANDROID STUDIO

我有至少2个活动,其中有EditTexts,你可以输入/更新数据..但在我的设备上,我总是要按后退按钮摆脱弹出的键盘.输入值后,有没有办法解除它?如果是这样,代码是什么,你会把它放在哪里.或者让它遍历字段或其他东西..我只是希望它在用户完成输入时消失.

keyboard android android-softkeyboard android-edittext android-activity

-2
推荐指数
1
解决办法
3685
查看次数

如何隐藏Android软键盘?

我在Linearlayout中有两个EditText视图和一个Button.完成edittext中的写入后,我想隐藏Android虚拟键盘,我该怎么做?

android android-softkeyboard android-edittext android-virtual-keyboard

-5
推荐指数
1
解决办法
886
查看次数