而无需任何引用到Android资源

而无需任何引用到Android资源

本文介绍了设置微调填充数据,而无需任何引用到Android资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

忙于创建与微调(下拉列表)编程的接口。为了填充数据,你需要一个(阵列)适配器。我不明白的是为什么你需要一个Android资源的引用都一样android.R.layout.simple_spinner_dropdown_item。是否有可能来填充Web服务的数据微调,没有任何提及这样一个Android资源?如果不是,为什么不和如何把这个资源的样子,在一个环境没有布局的。如果可能的话,请告诉我怎么样,因为谷歌是没有帮助在这里(对我来说)。

在此先感谢!

更新:

 微调微调=新的微调(this.getActivity());
ArrayAdapter<串GT;适配器=新ArrayAdapter<串GT;(this.getActivity(),whatComesHere,清单);
spinner.setAdapter(DataAdapter的);
tableRow.addView(微调);

的问题是:什么来取代whatComesHere

先谢谢了。

更新 - 2

 <微调
    机器人:ID =@ + ID / spinner_admin_platform
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginLeft =5dip
机器人:layout_marginRight =5dip
机器人:layout_marginTop =5dip
机器人:layout_marginBottom =5dip
机器人:项=@阵列/ my_spinner/>


解决方案

下面是一个例子:

 私人无效FillCitySnipper(){
ArrayList的< MyCity> ListOfCity = db.LoadMyCity();
            // TODO自动生成方法存根
            如果(ListOfCity.size()大于0){
                微调微调=(微调),这
                        .findViewById(R.id.spnr_Cityname);
                ArrayAdapter< MyCity> spinnerArrayAdapter =新ArrayAdapter< MyCity>(
                        这个,
                        android.R.layout.simple_spinner_dropdown_item,
                        ListOfCity);
                spinner.setAdapter(spinnerArrayAdapter);
            }
    }

Busy creating an interface with spinner (dropdown) programmatically. To populate with data you need an (Array)Adapter. What I don't understand is why you need a reference to an Android resource at all, like "android.R.layout.simple_spinner_dropdown_item". Is it possible to populate the Spinner with webservice data, without any reference to such an Android resource? If not, why not and how should this resource look like, in an environment without layout's. If it is possible, please show me how, since google is no help here (to me).

Thanks in advance!

Update:

Spinner spinner = new Spinner(this.getActivity());
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.getActivity(), whatComesHere, list);
spinner.setAdapter(dataAdapter);
tableRow.addView(spinner);

The questions is: what to substitute for 'whatComesHere'?

thanks in advance.

Update-2

<Spinner
    android:id="@+id/spinner_admin_platform"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:entries="@array/my_spinner" />
解决方案

Here is an example:

 private void FillCitySnipper() {
ArrayList<MyCity> ListOfCity=db.LoadMyCity();
            // TODO Auto-generated method stub
            if (ListOfCity.size() > 0) {
                Spinner spinner = (Spinner) this
                        .findViewById(R.id.spnr_Cityname);
                ArrayAdapter<MyCity> spinnerArrayAdapter = new ArrayAdapter<MyCity>(
                        this,
                        android.R.layout.simple_spinner_dropdown_item,
                        ListOfCity);
                spinner.setAdapter(spinnerArrayAdapter);
            }
    }

这篇关于设置微调填充数据,而无需任何引用到Android资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 01:05