我的微调器没有显示我选择的值

时间:2016-04-19 08:42:10

标签: c# android xamarin

我知道为什么我的微调器没有显示我选择的值,但是当我滚动滚动条时,插入微调器的表格突然出现并继续我的项目选择功能?我已经搜索谷歌,但我没有找到任何解决方案。伙计们,请帮助我。提前谢谢。

以下是我在表格中创建动态微调器的代码:

public override View GetView(int row, int column, View convertView, ViewGroup parent)
    {
        KeyValuePair<int, T> id_type = table[row + 1].Values.ElementAt(column + 1);
            switch (id_type.Value.ToString())
            {
                case "spin1":
                    convertView = new Spinner(context);
                    ((Spinner)convertView).Id = id_type.Key;
                    ((Spinner)convertView).SetMinimumWidth(100);
                    ((Spinner)convertView).ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(cmb_select);
                    freqadp = new ArrayAdapter(context, Android.Resource.Layout.SimpleSpinnerItem, freqarr);
                    freqadp.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
                    ((Spinner)convertView).Adapter = freqadp;
                    break;
            }
    }

1 个答案:

答案 0 :(得分:1)

要在微调器中设置所选项目,您需要使用GitHubService gitHubService = ServiceFactory.createServiceFrom(GitHubService.class, GitHubService.ENDPOINT); gitHubService.getIssuesList() .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .map(issues -> Arrays.asList(issues)) .subscribe(adapter::add); 方法设置它:

Button customToastButton = (Button) this.findViewById(R.id.add_to_cart);
        customToastButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

                //get the LayoutInflater and inflate the custom_toast layout
                LayoutInflater inflater = getLayoutInflater();
                View layout = inflater.inflate(R.layout.cart_toast, (ViewGroup)
                        findViewById(R.id.toast_layout_root));

                //get the TextView from the custom_toast layout
                TextView text = (TextView) layout.findViewById(R.id.toastText);
                text.setText("Item as been added to cart");

                //create the toast object, set display duration,
                //set the view as layout that's inflated above and then call show()
                Toast t = new Toast(getApplicationContext());
                t.setDuration(Toast.LENGTH_SHORT);
                t.setView(layout);
                t.show();
            }
        });