Estou desenvolvendo um formulário onde quero adicionar o spinner, porem quando adiciono ele no arquivo xml, não aparece nada na tela, somente a caixa marcada como vocês podem ver abaixo:
Já adicionei as opções do meu spinner em STRINGS. Aqui esta meu arquivo xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:background="@android:color/background_light">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/nome1"
android:textColorHint="#9b9a9a"
android:hint="*Nome:"
android:textSize="14dp"
android:textColorLink="#050000"
android:backgroundTint="#020000"
android:textColor="#050000"
android:layout_above="@+id/email"
android:layout_alignLeft="@+id/msg"
android:layout_alignRight="@+id/msg"
android:layout_alignEnd="@+id/msg" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColorHint="#9b9a9a"
android:inputType="textPostalAddress"
android:ems="10"
android:id="@+id/email"
android:hint="*E-mail:"
android:textSize="14dp"
android:textColorLink="#050000"
android:backgroundTint="#020000"
android:textColor="#050000"
android:layout_above="@+id/msg"
android:layout_alignLeft="@+id/msg"
android:layout_alignStart="@+id/msg"
android:layout_marginBottom="36dp"
android:layout_alignRight="@+id/msg"
android:layout_alignEnd="@+id/msg" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColorHint="#9b9a9a"
android:inputType="phone"
android:ems="10"
android:id="@+id/telefone"
android:hint="Telefone:"
android:textSize="14dp"
android:textColorLink="#050000"
android:backgroundTint="#020000"
android:textColor="#050000"
android:layout_above="@+id/nome1"
android:layout_alignLeft="@+id/msg"
android:layout_alignRight="@+id/msg"
android:layout_alignEnd="@+id/msg" />
<Button
android:layout_width="85dp"
android:layout_height="40dp"
android:text="Enviar"
android:id="@+id/send"
android:layout_above="@+id/textView8"
android:layout_alignRight="@+id/textView8"
android:layout_alignEnd="@+id/textView8" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColorHint="#9b9a9a"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/endereco"
android:hint="Endereço:"
android:textSize="14dp"
android:textColorLink="#050000"
android:backgroundTint="#020000"
android:textColor="#050000"
android:layout_above="@+id/telefone"
android:layout_alignLeft="@+id/msg"
android:layout_alignRight="@+id/msg"
android:layout_alignEnd="@+id/msg" />
<EditText
android:layout_width="wrap_content"
android:layout_height="120dp"
android:gravity="top"
android:inputType="textMultiLine"
android:lines="5"
android:ems="10"
android:id="@+id/msg"
android:hint="*Mensagem"
android:textSize="14dp"
android:textColorHint="#9b9a9a"
android:layout_above="@+id/send"
android:layout_alignRight="@+id/send"
android:layout_alignEnd="@+id/send"
android:layout_alignLeft="@+id/textView8"
android:layout_alignStart="@+id/textView8"
android:backgroundTint="#020000"
android:textColor="#050000"
android:textColorLink="#050000" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinner"
android:layout_below="@+id/imageView"
android:layout_alignLeft="@+id/endereco"
android:layout_alignStart="@+id/endereco"
android:clickable="false"
android:spinnerMode="dropdown" />
</RelativeLayout>
E aqui está a minha classe onde é chamado a intent do formulário:
public class Reclame extends Cronograma implements AdapterView.OnItemSelectedListener{
Spinner opcoes;
Button btnSend;
EditText Nome;
String Subject;
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);
Subject = "Reclamação";
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);
opcoes = (Spinner)view.findViewById(R.id.spinner);
opcoes.setOnItemSelectedListener(this);
btnSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ArrayAdapter adapter = ArrayAdapter.createFromResource(v.getContext(), R.array.option, android.R.layout.simple_spinner_item);
opcoes.setAdapter(adapter);
String nome = Nome.getText().toString();
String message = Message.getText().toString();
String matricula = Endereco.getText().toString();
String telefone = Telefone.getText().toString();
String ema = Email.getText().toString();
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{"meu_email"});
email.putExtra(Intent.EXTRA_SUBJECT, Subject);
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(this, "Você selecionou: "+mtext.getText(), Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
}
O que estou fazendo de errado, que nao aparece o spinner?