I am creating a comma seperated file and don't want to give the user a way to confuse the app.
views:
45answers:
2
+1
A:
Just check the addTextChangedListener(TextWatcher watcher) method - add the listener, which will check the editText field when it changes.
LordTwaroog
2010-08-12 14:40:54
+1
A:
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
}
});
}
Aaron C
2010-08-12 14:42:09
I can use tabs [slaps forehead]. Thanks.
JackN
2010-08-12 16:15:27
Using Tabs does not necessarily solve the problem. Tabs are easily entered in text fields on Android, because many hardware keyboards have a tab key that, actually enters a tab into text fields. It probably be better to read up on good CSV formats (such as http://tools.ietf.org/html/rfc4180 ) and/or use one of dozens of available CSV libraries for Java.
RoToRa
2010-08-13 08:31:07