I am quite new to Java and am currently coding an Android application. In my "Shortcuts" class, I have this bit of code (more of course, but not useful to you, I don't think):
final String[] items = new String[]{ "Please select a category",scanner.getCategorys() };
@SuppressWarnings({ "unchecked", "rawtypes" })
ArrayAdapter<CharSequence> adapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item, items);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
selection.setAdapter(adapter);
I have another class named "Scanner", which has this code:
String categorys = "test";
public String getCategorys() {
return categorys;
}
This does work, and in my Spinner, I can fill in my "Please select a category" option with a single value (i.e "test"). The problem is, I would like to be able to select multiple categories. If I do this in "Shortcuts" class:
final String[] items = new String[]{ "Please select a category","test","test2" };
It would work, but I would like to set it from the "Scanner" class, so I tried this:
String[] categorys = "test","test2";
public String[] getCategorys() {
return categorys;
}
But it just gives me the error:
String cannot be converted to String[]
I would be grateful for any help.