小编The*_*mit的帖子

如何从searchview获取输入到textview

有没有其他方法来获取searchview的输入并将其放入textview?似乎getText()和setText()方法不适用于searchview.

要么

有没有办法将输入从EditText传输到Searchview?

请帮助我查找有关上述问题的必要资源/代码/方法.谢谢.这是我的代码:

public boolean onQueryTextChange(String newText) {
    // TODO Auto-generated method stub
    showResults(newText);
    return false;
}

@Override
public boolean onQueryTextSubmit(String query) {
    // TODO Auto-generated method stub

    tvInput = (TextView) findViewById (R.id.tvInput);
    showResults(query);
//  searchView.getQuery().toString();
    tvInput.setText(searchView.getQuery().toString());
    return false;
}
Run Code Online (Sandbox Code Playgroud)

我也是以其他方式做到的.这里:

tvInput = (TextView) findViewById (R.id.tvInput);
                tvInput.setText(searchView.getQuery());
Run Code Online (Sandbox Code Playgroud)

android searchview

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

如何在android 4.2中使用toUppercase(locale)?

在此输入图像描述我使用android 4.2 SDK,我收到了这行代码的警告:

String text0 = tagalogText.getText().toString();
String textA = text0.substring(0, 1).toUpperCase() + text0.substring(1).toLowerCase();
Run Code Online (Sandbox Code Playgroud)

当我将鼠标悬停在它上面时,它说:

Implicitly using the default locale is a common source of bugs: Use toUpperCase(Locale) instead.
Run Code Online (Sandbox Code Playgroud)

隐式使用默认语言环境是错误的常见来源:使用toLowerCase(Locale).

我从Java复制代码,而不是Java for android.有谁知道如何删除此错误?为什么它现在是使用这种方法的首选方式?

android

7
推荐指数
2
解决办法
8718
查看次数

如何禁用searchview?

你可以帮助我按下按钮时如何禁用searchview吗?我正在尝试这段代码:

searchView.setEnabled(false);
                searchView.setFocusableInTouchMode(false);
                searchView.clearFocus();
Run Code Online (Sandbox Code Playgroud)

但它似乎无法正常工作.我仍然可以在searchview中输入文字.

谢谢.. :))

android searchview

5
推荐指数
2
解决办法
6003
查看次数

标签 统计

android ×3

searchview ×2