如何删除searchview中的箭头崩溃?

时间:2015-05-19 19:28:21

标签: android searchview

我只是把searchView放在工具栏上,但是当我崩溃searchView时我遇到了问题我在这张照片中提到了箭头我在菜单文件夹中提到了..searchview给了一些如何删除这个箭头的建议.... ..谢谢提前searchview screenshot image

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"

    tools:context="com.play.findnearplace.MainActivity" >

    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:title="@string/action_settings"
        app:showAsAction="never"/>

    <item android:id="@+id/action_search"
          android:title="@string/action_search"
          android:icon="@drawable/search"
         app:showAsAction="always|collapseActionView"

          app:actionViewClass="android.support.v7.widget.SearchView" />

</menu>

MainActivity.java

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);

        SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();

        searchView.setSubmitButtonEnabled(true);
        searchView.setOnQueryTextListener(this);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub

    }

    @Override
    public boolean onQueryTextChange(String newText) {
        // TODO Auto-generated method stub
         if (TextUtils.isEmpty(newText))
          {
             filter.filter("");
            }
          else
          {
              filter.filter(newText.toString());
            }
        return true;
    }

    @Override
    public boolean onQueryTextSubmit(String arg0) {
        // TODO Auto-generated method stub
        return false;
    }

1 个答案:

答案 0 :(得分:1)

删除此行以摆脱该箭头:

searchView.setSubmitButtonEnabled(true);

请参阅searchView submit button

的文档