title: disable space in edittext in Android
body: <p>I'm  trying to prevent a space/enter pressing into edittext. 
  I found code for preventing a space but it`s not working for me. please tell me what is the problem and how I can fix it</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>package com.example.apc.myapplication;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.text.Editable;
  import android.widget.TextView;
  
  public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
      }
      @Override
      public void afterTextChanged(Editable s) {
          TextView inputView = (TextView) findViewById(R.id.editText);
          String result = s.toString().replaceAll(" ", "");
          if (!s.toString().equals(result)) {
              inputView.setText(result);
              inputView.setSelection(result.length());
          }
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Error:(21, 21) error: cannot find symbol method setSelection(int)
  Error:Execution failed for task ':app:compileDebugJavaWithJavac'.</p>
  
  <blockquote>
    <p>Compilation failed; see the compiler error output for details.
    Error:(15, 5) error: method does not override or implement a method from a supertype
    Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
    Compilation failed; see the compiler error output for details.</p>
  </blockquote>