所选项目犯规秀上微调的android [英] selected item doesnt show on the spinner android

查看:101
本文介绍了所选项目犯规秀上微调的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个微调,我添加了一个自定义样式的好手。问题是,当我选中它不显示在微调的项目,但是当我使用Android微调风格它显示了我的选择微调。有没有更多的代码添加到使它工作吗?否则,全部的寄托微调作品。当在微调中选择一个项目显示一个文本我写的应用程序。这些东西的工作。但它不显示我选择了什么。

I have a spinner and I have added a custom style to spinner. Problem is when I select an item it doesnt show up on the spinner but when I use android spinner style it shows what I selected on the spinner. Is there any more coding to add to make it work? Otherwise everthing of the spinner works. I have written the app when an item is selected in spinner to show a text. These things work. But it doesnt show what I selected.

下面是我的code

MyAdapter  dataAdapter3 = new MyAdapter(this, R.layout.spinner, list3);
spinner1.setAdapter(dataAdapter3);

3名单一referes列表

list 3 referes a list

List<String> list3 = new ArrayList<String>();

下面是类定制微调风格

public class MyAdapter extends ArrayAdapter<String>
    {
      private List<String> listString = new ArrayList<String>();

      public MyAdapter(Context context, int textViewResourceId, List<String> objects) {
        super(context, textViewResourceId, objects);

      this.listString  = objects;
      }

      @Override
      public View getDropDownView(int position, View convertView,ViewGroup parent) {
            return getCustomView(position, convertView, parent);
      }

      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
            return getCustomView(position, convertView, parent);
      }

      public View getCustomView(int position, View convertView, ViewGroup parent) {

       LayoutInflater inflater=getLayoutInflater();
       View row=inflater.inflate(R.layout.spinner, parent, false);
       TextView label=(TextView)row.findViewById(R.id.textView1);
       label.setText(listString.get(position)); 

       return row;

      }
    }

请有谁能够告诉我是否在这里做什么错误?
这是微调是如何表演的时候我选择的项目

please can anybody tell whether I have done any mistake here? This is how spinner is shows when I selected item

推荐答案

我想在这个问题上几天。其实code为pretty确定。问题是在spinner.xml文件。我又增加了一个大的填充,以TextView的。因此,虽然纺丝器的工作原理是不可见的离心器所选择的项目。关键是我忘了xml文件。 :D

I tried several days on this problem. Actually code is pretty ok. problem was in the spinner.xml file. I had added a large padding to textview. Therefore, though spinner works it is not visible the selected item on spinner. Point is I forget xml file. :D

这篇关于所选项目犯规秀上微调的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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