In a messaging app, in my WriteMessageActivity
, I have a spinner for choosing who can see my messages.
I have three options - visible to everyone - my friends only - select friends
Now when I click SelectFriends
from spinner it opens ChooseContactsActivity
. From there I can select a number friends that can see my message.
When I select my contacts I click the add button
in my ChooseContactsActivity
, and pass those contacts back to WriteMessageActivity
. It works fine.
Now I have a small problem, After I selected my friends, if I want to reopen ChooseContactsActivity
again, I first have to select one of the other two options in the spinner (either visible to everyone
, or my friends only
), and then click on the select friends option again, I cannot click on the selected option directly to reopen it again.
Spinner:
vissibleToSpinner = (Spinner) findViewById(R.id.spinnerVissibleTo);
adapter = ArrayAdapter.createFromResource(this, R.array.spinner_vissible_to, R.layout.spinner_center_item);
adapter.setDropDownViewResource(R.layout.spinner_center_item);
vissibleToSpinner.setAdapter(adapter);
vissibleToSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
((TextView) parent.getChildAt(0)).setTextColor(Color.WHITE);
((TextView) parent.getChildAt(0)).setTextSize(14);
((TextView) parent.getChildAt(0)).setAllCaps(true);
((TextView) parent.getChildAt(0)).setAllCaps(true);
switch (position) {
case 0:
mShowTo.setText("0");
break;
case 1:
mShowTo.setText("-1");
Toast.makeText(parent.getContext(), "Message will be visible to your friends only", Toast.LENGTH_SHORT).show();
break;
case 2:
mShowTo.setText("TODO");
Intent intent = new Intent(MessageActivity.this, ChooseContactsActivity.class);
startActivityForResult(intent, 1);
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});