Code example for AutoCompleteTextView

Methods: getWindowToken

0
		username.setOnEditorActionListener(new OnEditorActionListener() {
			 
			@Override 
			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
				InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
				imm.hideSoftInputFromWindow(username.getWindowToken(), 0);
				return true; 
			} 
		}); 
	} 
 
	@Override 
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present. 
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true; 
	} 
	 
	public void startButton(View v){
		AutoCompleteTextView username = (AutoCompleteTextView)this.findViewById(R.id.usernames);
		String input = username.getEditableText().toString();