简体   繁体   English

如何使用 imageview 作为微调器

[英]how to use imageview as spinner

i ve an issue that i use an imageview dropdown but I don't know how to set data to imageview, so if there is anyone who can help me.i want to use it like an spinner when u click the spinner it display data that u fetch it in it , so my question is how to fetch data to image view and display it this is my code :我有一个问题,我使用 imageview 下拉菜单,但我不知道如何将数据设置为 imageview,所以如果有人可以帮助我。我想在您单击微调器时像微调器一样使用它,它显示数据你在里面取它,所以我的问题是如何取数据到图像视图并显示它这是我的代码:

dropDownArrow2 =(ImageView)findViewById(R.id.dropDownImage2);
 dropDownArrow2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            alimentsAutoComp.showDropDown();
        }
    });

From you post I understand you have a spinner and an imageview next to it and you want to expand the spinner when the user clicks on the imageview.从您的帖子中我了解到您有一个微调器和一个图像视图,并且您想在用户单击图像视图时展开微调器。 You can call the performClick() method of the spinner view inside your imageview's listener:您可以在 imageview 的侦听器中调用微调视图的 performClick() 方法:

Spinner yourSpinnerView = (Spinner) view.findViewById(R.id.yourSpinnerView);
dropDownArrow2 = (ImageView) view.findViewById(R.id.dropDownImage2);
dropDownArrow2.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        yourSpinnerView.performClick();
    }
});

If you want to populate the spinner with data you can copy the code from the developer's website here .如果您想用数据填充微调器,您可以在此处从开发人员的网站复制代码。 Not sure what you mean about adding data to the imageview.不确定您将数据添加到图像视图的意思。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM