Let say I have this String array "{Unclaimed", "Lost/Stolen", "Damaged/Defective", "Pawned", "Not Turned Over", "Others"} and I want to remove the first one which is Unclaimed , It will remove if aat_distribution_status is being clicked is there anyway to remove it? I tried Reasons = Reasons.Skip(1).ToArray() but it doesn't work
My sample code
AutoCompleteTextView aat_reason_not_presented;
aat_reason_not_presented = findViewById(R.id.aat_reason_not_presented);
String[] Reasons = new String[]{"Unclaimed", "Lost/Stolen", "Damaged/Defective", "Pawned", "Not Turned Over", "Others"};
ArrayAdapter<String> adapterYesNo = new ArrayAdapter<>(getApplicationContext(), android.R.layout.simple_spinner_item, Reasons);
adapterYesNo.setDropDownViewResource(simple_spinner_dropdown_item);
aat_reason_not_presented.setAdapter(adapterYesNo);
aat_distribution_status.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View arg1, int pos, long id) {
Reasons = Reasons.Skip(1).ToArray() //Trying to remove first element of reasons but it didn't work
}
});
{a, b, c}and you want to get rid ofayou can't modify that array into{b, c}(since now its size is 2 not 3), but what you can do is shifting elements and filling blanks withnulllike{b, c, null}(or use other values representing no element). To have array with reduced size you will need to create new array of that size and fill it with data you want. Alternatively you can use List which is resizable.