SearchView edittext is always null

后端 未结 3 1922
小鲜肉
小鲜肉 2020-12-16 01:30

I always get that textView is null when doing this:

public boolean onCreateOptionsMenu(Menu menu) {

        getMenuInflater().inflate(R.menu.main, menu);

          


        
3条回答
  •  一整个雨季
    2020-12-16 02:04

    I'm using action bar of appcompat v7 and my solusion is:

    TextView searchText = (TextView) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
    

    Hope this help.

提交回复
热议问题