我是新来的android。我需要获得editText's价值来搜索某些东西。但是当我运行程序时,错误出现在null pointer exception.
“EditText etSearch”没有得到它的文本。
请帮我。谢谢。
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_search) {
AlertDialog.Builder builder = new AlertDialog.Builder(
MainActivity.this);
// Get the layout inflater
LayoutInflater inflater = MainActivity.this.getLayoutInflater();
// Inflate and set the layout for the dialog …Run Code Online (Sandbox Code Playgroud)