Invisible spinner in form

Asked

Viewed 350 times

1

I’m developing a form where I added the spinner, the code went all right, I was able to add and get the selected item, the problem is in the visibility of the spinner. It only appears on the screen when I click on top, and right after I choose the option it returns to be invisible. I’ve done everything and do not find the error. erro

erri

Here is the xml:

<Spinner
    android: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 problem?

RAMARAL I did what you suggested and it was like this: er

  • 1

    I think it would be better to expose also the code that has related to this

  • 1

    Retire android:background="#ffffff" or switch to android:background="#000000"

  • Taking advantage of the Miguel hook, how do I leave my form with a more attractive theme? I’m finding it half "dead". I’ve seen better forms done there.

  • 1

    The problem is that the color of the spinner font is white. You have some custom style applied?

  • I have no extension

  • Solved? You can show the xml of the form layout?

  • It was solved yes. It was the same color as the background.

Show 2 more comments

1 answer

2


Dear,

It is strongly recommended that you use Appcompatspinner instead of the default Spinner for various compatibility reasons. But what must be wrong is the display style and why it is appearing in a strange way. In one of my codes, I found an excerpt 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);
}
  • Matthew thanks for your help, you could help me with this other problem: http://answall.com/questions/131295/problemas-com-o-layout-da-aplica%C3%A7%C3%A3o-em-diversos-celulares/131316#131316 ??

Browser other questions tagged

You are not signed in. Login or sign up in order to post.