I want to know if there is any method with which I can remove a specific character from EditText. I want to remove the charter from EditText, indicating the position in the text editor is there something like removeAt()for EditText?
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button b1=(Button)findViewById(R.id.button1);
final EditText ed1=(EditText)findViewById(R.id.editText1);
b1.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
ed1.removeAt(5);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
ADDITIONAL INFORMATION
The main problem is that I want to make the text bold inside the edittext, but not all the text. Text typed after turning on the bold button (bold is my toggle button). ok here is the code
ed1.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
int i = 0;
switch(event.getAction())
{
case KeyEvent.ACTION_UP:
if(bold.isChecked())
{
i=ed1.getSelectionStart();
ed1.append(Html.fromHtml("<b>"+ed1.getText().toString().charAt(i-1)+"</b>"));
}
return true;
}
return false;
}
});
the problem is that I get a double character, which is a normal character, and then bold again, so I want to remove normal characters by indicating the position there
source
share