封闭微调的文本颜色文本、颜色

2023-09-12 03:34:21 作者:带你翱翔到天黑!

据我所知,封闭的微调实际上是一个查看,我想。但我猜测它有一个的TextView 有没有什么地方来显示文本。我如何获得访问该的TextView 这样我就可以改变文字颜色?

编辑:我要改变这种编程上的苍蝇,而不是在XML

  TextView的V =(TextView中)getView(mySpinner);

v.setTextColor(.....
 

这不工作...

感谢您!

  array_typ =新的String [5];
    array_typ [0] =pressure;
    array_typ [1] =级别;

    array_typ [2] =超龄;
    array_typ [3] =下;
    array_typ [4] =两者;


    adaptertyp =新的ArrayAdapter<对象>(这一点,R.layout.simple_spinner_item,array_typ);
    typ.setAdapter(adaptertyp);
 
手机游戏最新软件教程 最新最热门安卓手机软件教程 去秀手游

解决方案   

据我所知,封闭的微调其实是一个观点,我觉得。

是的。具体来说,就是无论你告诉你的 SpinnerAdapter 以创建。

  

但我猜测它有一个TextView有某处显示文本。

这将取决于你告诉你的 SpinnerAdapter 以创建。

  

我如何获得访问该TextView的,所以我可以改变文字颜色?

在理想情况下,你不 - 你给它正确的颜色摆在首位,通过任何你告诉你的 SpinnerAdapter 以创建。如果颜色各不相同,覆盖 getView() SpinnerAdapter 并更改该点的颜色。

在紧要关头,你可以尝试调用 getSelectedView()来获得当前查看正在显示的封闭微调,但其他的改动,您在此处可以在用户的​​下一个选择淘汰,替代颜色可能会返回以后,如果前面查看被回收。

I understand that the closed spinner is actually a View, I think. But I am guessing it has a TextView there somewhere to show the text. How do I get access to that TextView so I can change the textcolor?

EDIT: I need to change this programatically on the fly, not in the XML.

TextView v = (TextView) getView(mySpinner);

v.setTextColor(.....

This doesnt work...

Thank you!

    array_typ=new String[5];
    array_typ[0]="Pressure";
    array_typ[1]="Level";

    array_typ[2]="Overage";
    array_typ[3]="Under";
    array_typ[4]="Taken";


    adaptertyp = new ArrayAdapter<Object>(this,R.layout.simple_spinner_item, array_typ);
    typ.setAdapter(adaptertyp);

解决方案

I understand that the closed spinner is actually a View, I think.

Yes. Specifically, it is whatever you told your SpinnerAdapter to create.

But I am guessing it has a TextView there somewhere to show the text.

That would depend on what you told your SpinnerAdapter to create.

How do I get access to that TextView so I can change the textcolor?

Ideally, you don't -- you give it the right color in the first place, via whatever you told your SpinnerAdapter to create. If the color varies, override getView() in your SpinnerAdapter and change the color at that point.

In a pinch, you can try calling getSelectedView() to get the current View being shown by the closed Spinner, but whatever change you make here may be eliminated on the user's next selection, and the alternate color may return later on if the earlier View gets recycled.