作者:teemitop | 来源:互联网 | 2023-05-19 07:46
HereisanMultiAutocompleteTextView,whichgetsthefavsportsfromtheuser,andthethesportsar
Here is an MultiAutocompleteTextView ,which gets the fav sports from the user ,and the the sports are now stored in the array ,i want to store this values in array in MySQL Database.
这里有一个MultiAutocompleteTextView,它从用户那里得到最喜欢的运动,而这些运动现在存储在数组中,我想将这些值存储在MySQL数据库中的数组中。
Here is my code:
这是我的代码:
String[] str = {"Foot Ball", "Volley Ball", "Basket Ball",
"Golf", "F1", "Marathon "};
final MultiAutoCompleteTextView mt = (MultiAutoCompleteTextView)
findViewById(R.id.MyTags);
mt.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
ArrayAdapter adp = new ArrayAdapter(this,android.R.layout.simple_dropdown_item_1line, str);
mt.setThreshold(1);
mt.setAdapter(adp);
Button add=(Button)findViewById(R.id.add);
assert add != null;
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String text = mt.getText().toString();
if (text != null && text.length() > 0) {
text = text.substring(0, text.length() - 1);
}
String sports[] = text.split(","); // countries array will have all the countries entered in multiAutoCompleteTextView
for (String s : countries) {
Toast.makeText(Profile.this, s, Toast.LENGTH_SHORT).show();
}
}
});
}
2 个解决方案