[英]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.