[英]Change text of a TextView Layout inside spinner adapter
我的布局包含一个正在微调器中使用的TextView。 如何根据我的微调器在运行时更改android:text
。
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textSize="18sp"
android:textColor="#808080"
android:text="@string/month"/>
如果要在微调器中查找当前选定项目的文本,然后将其设置为另一个textview,则需要执行此操作
Spinner spinner = (Spinner) findViewById(R.id.idOfSpinner);
TextView textView = (TextView)findViewById(R.id.idOfTextView);
textView.setText(spinner.getSelectedItem().toString());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.