Invisible Spinner in form

1

I'm developing a form where I added the spinner, the code worked, I was able to add and pick the selected item, the problem is in the spinner's visibility. It only appears on the screen when I click on it, and soon after I choose the option it goes back to being invisible. I have already done everything and I do not find the error.

Hereisthexml:

<Spinnerandroid:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/spinner"
    android:background="#ffffff"
    android:layout_above="@+id/endereco"
    android:spinnerMode="dialog"
    android:visibility="visible"
    android:theme="@style/Animation.AppCompat.DropDownUp" />

And the form class:

public class Reclame extends Cronograma implements AdapterView.OnItemSelectedListener{

Spinner option;
Button btnSend;
EditText Nome;
EditText Message;
EditText Endereco;
EditText Telefone;
EditText Email;
@Override
public View onCreateView(LayoutInflater inflater,
                         ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.reclame, container, false);



    Nome = (EditText) view.findViewById(R.id.nome1);
    Message = (EditText) view.findViewById(R.id.msg);
    Endereco = (EditText) view.findViewById(R.id.endereco);
    Telefone = (EditText) view.findViewById(R.id.telefone);
    Email = (EditText) view.findViewById(R.id.email);
    btnSend = (Button) view.findViewById(R.id.send);
    option = (Spinner)view.findViewById(R.id.spinner);
    option.setOnItemSelectedListener(this);
    ArrayAdapter adapter = ArrayAdapter.createFromResource(getActivity(), R.array.option, android.R.layout.simple_spinner_item);
    option.setAdapter(adapter);

    btnSend.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {



            String nome = Nome.getText().toString();
            String message = Message.getText().toString();
            String matricula = Endereco.getText().toString();
            String telefone = Telefone.getText().toString();
            String assunto = option.getSelectedItem().toString();
            String ema = Email.getText().toString();
            Intent email = new Intent(Intent.ACTION_SEND);
            email.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
            email.putExtra(Intent.EXTRA_SUBJECT, assunto);
            email.putExtra(Intent.EXTRA_TEXT, "Nome: " +nome +'\n'+  "Endereço: "+matricula + '\n'+ "Telefone: "+telefone + '\n'+ "E-mail: "+ema + '\n'+ '\n'+message);


            email.setType("message/rfc822");
            startActivity(Intent.createChooser(email, "Selecione o serviço de e-mail:"));
        }
    });
    return view;
}

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    TextView mtext = (TextView) view;
    //Toast.makeText(getActivity(), "Você selecionou: "+mtext.getText(), Toast.LENGTH_SHORT).show();
}

@Override
public void onNothingSelected(AdapterView<?> parent) {

}

How do I fix this?

RAMARAL did what he suggested and it looked like this:

    
asked by anonymous 28.05.2016 / 17:41

1 answer

2

Dear,

We strongly recommend using AppCompatSpinner instead of the default Spinner, for a variety of compatibility reasons. But what must be wrong is the display style and why it is appearing in a weird way. In one of my codes, I found a passage that can help you. See if it helps:

private void popularSpinnerClassificacao(final TipoAtendimento tipoAtendimento){
        String[] arrayClassificacoes = getResources().getStringArray(R.array.classificacao_atendimento);
        if(tipoAtendimento.equals(TipoAtendimento.LEADS)){
            arrayClassificacoes = getResources().getStringArray(R.array.classificacao_atendimento_leads);
        }

        adapterClassificacao = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, arrayClassificacoes);
        adapterClassificacao.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spnClassificacao.setAdapter(adapterClassificacao);
        spnClassificacao.setOnItemSelectedListener(this);
}
    
31.05.2016 / 20:33