如何将项目动态的机器人加入到微调? [英] how to add items to the spinner dynamically in android?

查看:139
本文介绍了如何将项目动态的机器人加入到微调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将项目动态的机器人加入到微调?

解决方案

 微调微调=(微调)findViewById(R.id.mySpinner);
ArrayAdapter<字符串> spinnerAdapter =新的ArrayAdapter<字符串>(这一点,android.R.layout.simple_spinner_item,android.R.id.text1);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(spinnerAdapter);
spinnerAdapter.add(价值);
spinnerAdapter.notifyDataSetChanged();
 

以上是万一阵列适配器,我相信你知道如何填充值与ArrayAdapter。

我们如何才能做到这一点的情况下SimpleCursorAdapter,即如果我们有2纺纱,如果我们选择一个微调(即获得由SimpleCursorAdapter的值)的值取决于一些条件的其他微调应该充满价值。如何才能做到这一点?

how to add items to the spinner dynamically in android?

解决方案

Spinner spinner = (Spinner)findViewById(R.id.mySpinner);
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, android.R.id.text1);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(spinnerAdapter);
spinnerAdapter.add("value");
spinnerAdapter.notifyDataSetChanged();

the above is in case of the array adapter, I believe you know how to populate values with ArrayAdapter .

How can we do this in case of the SimpleCursorAdapter, i.e if we have 2 spinners and if we select the values of one spinner (that is getting the value from SimpleCursorAdapter) depending on some criteria the other spinner should be filled with values. how can we achieve that?

这篇关于如何将项目动态的机器人加入到微调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆