Android:如何使用微调项设置标签

标签 android android-spinner

是否可以使用微调项设置标签。我想将我的 bean 对象设置为每个微调项的标签,这可能吗?

最佳答案

希望这对你有帮助:

如下所示创建您自己的 CustomAdapter 并在 getView() 方法中添加标签..

自定义适配器:

public class MySpinnerAdapter extends BaseAdapter  {

    private Activity context;

    public MySpinnerAdapter (Activity context){
        this.context=context;
    }

    @Override
    public int getCount() {
        return 0;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        RelativeLayout item= (RelativeLayout)context.getLayoutInflater().inflate(R.layout.<your spinner item layout name>, null); 

      //set your data to layout components

      item.setTag(<your tag object>);

        return item;
    }
}

关于Android:如何使用微调项设置标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20902102/

相关文章:

Android:微调器 setSelection 不起作用

java - 如何检测 Spinner 是否在 Android 上单击打开

android - 如何将 Spinner 默认值设置为 null?

android - 执行过程后,Spinner 对象不会接受第二个输入

android - RecyclerView ItemTouchHelper 如何锁定滑动项目?

android - 如果将 checkSelfPermission() 提取到方法中,仍会显示检查权限的警告

android - 显示对话框时出现 BadTokenException

android - 只要 EditText 字段不为空,如何启用微调器

android - 获取所有 Android 设备图像

android - 如何在 android 和 ios 上运行 angular 7 应用程序?