I am creating a comma seperated file and d开发者_开发百科on't want to give the user a way to confuse the app.
Following what RoToRa said, you can delimitate the file using tabs instead.
If you do want to disallow commas, you can add a TextWatcher to modify the string before it is posted to the GUI:
EditText text;
private void foo()
{
text.addTextChangedListener(new TextWatcher()
{
public void onTextChanged(CharSequence s, int start, int before, int count)
{
}
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
}
public void afterTextChanged(Editable s)
{
// modify string here
}
});
}
Just check the addTextChangedListener(TextWatcher watcher) method - add the listener, which will check the editText field when it changes.
精彩评论