简体   繁体   English

想要在单击按钮时在textview上显示微调框选择的值

[英]Want to display spinner selected values on textview when button is clicked

I have taken 3 edittext in my form and three spinner. 我的表格中有3个edittext,还有3个微调器。 I can easily get the data from edit text and display it on Textview, but the problem is how to get the data from spinner and display all the edit text and spinnner values in textview. 我可以轻松地从编辑文本中获取数据并将其显示在Textview上,但是问题是如何从微调器中获取数据并在textview中显示所有编辑文本和微调器值。 I am creating a form in which when the button is clicked all the data from edittext text and spinner is displayed on Textview 我正在创建一个表单,其中单击按钮时,来自edittext文本和微调框的所有数据将显示在Textview上

请试试这个:

String textValue= yourSpinner.getSelectedItem().toString();

Try this 尝试这个

Button btn = (Button) findViewById(R.id.your_btn);
btn.setOnClickListner(new OnClickListener {

public void onClick(View v)
 {
   String spinnerStr = yourSpinner.getSelectedItem().toString();
   String editTextStr = yourEditText.getText().toString();
   yourTextView.setText(spinnerStr + editTextStr);
 }
}
);

Try this: 尝试这个:

Spinner spinner = (Spinner) findViewById(R.id.spinner);
TextView textView = (TextView) findViewById(R.id.textView);

button.setOnClickListener(new OnClickListener() {
public void onClick(View v){ 


    String item= spinner .getSelectedItem().toString();
    textView .setText(item);

}
});

暂无
暂无

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

相关问题 单击按钮时,添加了另一行元素(TextView,Spinner等) - When button clicked, another line of elements (TextView, Spinner, etc) are added 在 textview 中的选定微调器中显示单词 - display the word in the selected spinner in the textview 单击按钮时如何在TextView中显示ArrayList? - How to display an ArrayList in a TextView when a Button is clicked? 如何在 Android 中选择 Spinner 选项时显示不同的 textview - How to display different textview when Spinner option is selected in Android 当在微调器中选择项目然后单击按钮时,从数据库填充Listview - Populating Listview from database when item selected in a spinner then button clicked ANDROID-将选定的微调框显示为另一个活动作为textview - ANDROID - Display selected spinner into another activity as textview 如何设置微调器 textview 我想要一个单独的 textview 来显示微调器中的文本是否被单击? - how to set spinner textview I want a separate textview to show if the text in the spinner is clicked? 单击时微调器选择的项目不显示 - Spinner selected item not showing when clicked 选择微调器项目后,我希望按钮文本成为选定的微调器项目。 或者我们可以在 string.xml 中做到这一点吗? - When the spinner item is selected, I want the button text to be the selected spinner item. or can we just do it in string.xml? 将选定的Spinner数组放入TextView - Selected Spinner array into TextView
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM