我有spinner
替换了我的strings xml
中由硬编码值填充的默认custom spinner and populated it dynamically in java
。
我使用了strings.xml
,但我不需要为此做这件事。
我是否必须填充列表然后将其添加到java中的微调器?如果是这样,我如何从 List<String> spinnerList = new ArrayList<String>();
//spinnerList.addAll(R.array.array_spinner);error here, doesnt like this?????????????
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.spinner_custom, spinnerList);
spinnerSports.setAdapter(adapter);
<resources>
<string-array name="array_custspinner">
<item>item1</item>
<item>item2</item>
</string-array>
</resources>
数组元素填充列表?
{{1}}
答案 0 :(得分:1)
// spinnerList.addAll(R.array.array_spinner);这里错误,不喜欢 此?????????????
是的,这是正确的。在您的情况下,addAll期望与buildTabEmail
,private FormLayout buildTabEmail(Map<String, Propriedades> props) {
// definição dos campos
this.servidor = TextFieldFactory.simples("Servidor:", 20);
this.porta = TextFieldFactory.simplesNumerico("Porta:", 5);
this.usuairoEmail = TextFieldFactory.simples("Usuário:", 15);
this.passwordEmail = PasswordFieldFactory.simples("Senha:", 10);
this.emissorMensagem = TextFieldFactory.simples("Emissor da Mensagem:", 30);
this.sslPort = CheckBoxFactory.marginTop5("SSL");
this.tlsPort = CheckBoxFactory.marginTop5("TLS");
// adição ao mapa
this.configMap.put(PropsHandler.CONST_EMAILPORT, new VO(porta, props.get(PropsHandler.CONST_EMAILPORT)));
this.configMap.put(PropsHandler.CONST_EMAILEMISSOR, new VO(emissorMensagem, props.get(PropsHandler.CONST_EMAILEMISSOR)));
this.configMap.put(PropsHandler.CONST_EMAILSENHA, new VO(passwordEmail, props.get(PropsHandler.CONST_EMAILSENHA)));
this.configMap.put(PropsHandler.CONST_EMAILUSER, new VO(usuairoEmail, props.get(PropsHandler.CONST_EMAILUSER)));
this.configMap.put(PropsHandler.CONST_EMAILHOST, new VO(servidor, props.get(PropsHandler.CONST_EMAILHOST)));
this.configMap.put(PropsHandler.EMAIL_TLS, new VO(tlsPort, props.get(PropsHandler.EMAIL_TLS)));
this.configMap.put(PropsHandler.EMAIL_SSL, new VO(sslPort, props.get(PropsHandler.EMAIL_SSL)));
preencheDadosEdicao();
FormLayout tabEmail = new FormLayout();
tabEmail.addComponent(servidor);
tabEmail.addComponent(porta);
tabEmail.addComponent(usuairoEmail);
tabEmail.addComponent(passwordEmail);
tabEmail.addComponent(emissorMensagem);
tabEmail.addComponent(sslPort);
tabEmail.addComponent(tlsPort);
return tabEmail;
}
相同类型的Collection
。但是您提供了List
,即您要使用的数组ID。使用
String
通过这种方式,您可以获得可修改的int
,其中包含您在List<String> spinnerList = new ArrayList<String>
(Arrays.asList(getResources().getStringArray(R.array.array_custspinner)));