For example, you pressed the spacebar, but it turned out "_"?

Source:

o = (EditText)findViewById(R.id.mainEditText); (findViewById(R.id.mainButton)).setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("мой текст"+o.getText() )));}}); 

And after that, words go through the space in EditText or "o", but you need to put "_" instead of a space

  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

3 answers 3

  1. Hang onTextChangeListener on EditText
  2. Check in it that the space was pressed.
  3. Replace it with an underscore.
      EditText eTxt; 

    ...

     eTxt = (EditText) findViewById(R.id.eTxt); eTxt.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s.toString().contains(" ")){ eTxt.setText(s.toString().replace(" ", "_")); eTxt.setSelection(s.length()); } } }); 

      Thanks for the feedback, but this is a bit not what it gave me an error. I found a way out easier for those who will be interested.

       o=(EditText)findViewById(R.id.mainEditText); k=(EditText)findViewById(R.id.text); k=(EditText)findViewById(R.id.text); (findViewById(R.id.mainButton)).setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("https://"+k.getText()+".m.wikipedia.org/wiki/"+o.getText().toString ().replaceAll(" ","_") ))); } }); //vk.com/moto_ride_x } }