Android:不在搜索视图中输入任何内容

时间:2015-09-29 10:25:35

标签: android

我在android应用程序的弹出窗口中使用了搜索视图,用于在searchView中显示listview的任何类型。但无法在搜索视图中键入任何内容或显示键盘。有人建议我如何使用搜索视图。这是我的代码。

private void initSearchview()
    {
        LayoutInflater inflater = (LayoutInflater) AllPosts_Page.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.search_view, (ViewGroup) findViewById(R.id.search_popup));
        pwindo = new PopupWindow(layout, 700, 115, true);
        pwindo.showAtLocation(layout, Gravity.TOP, 10, 10);
        pwindo.update(50, 50, 720, 90);

        search=(SearchView)layout.findViewById(R.id.searchView_Text);
        search.setQueryHint("Search Here");

        search.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {

            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                // TODO Auto-generated method stub

                Toast.makeText(getBaseContext(), String.valueOf(hasFocus),
                        Toast.LENGTH_SHORT).show();
            }
        });
        search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

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

                Toast.makeText(getBaseContext(), query,
                        Toast.LENGTH_SHORT).show();

                return false;
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                // TODO Auto-generated method stub

                Toast.makeText(getBaseContext(), newText,
                        Toast.LENGTH_SHORT).show();
                return false;
            }
        });

        pwindo.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
        btnCancel = (Button) layout.findViewById(R.id.btnCancel);
        btnCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                pwindo.dismiss();
            }
        });

    }

先谢谢

0 个答案:

没有答案