How to get EditText value and display it on screen through TextView?

前端 未结 11 1952
南旧
南旧 2020-12-05 12:45

I want to get the user input for the EditText view and display it on the screen through TextView when the Button is clicked. I also, w

相关标签:
11条回答
  • 2020-12-05 13:06

    Try this->

    EditText text = (EditText) findViewById(R.id.text_input);

    Editable name = text.getText();

    Editable is the return data type of getText() method it will handle both string and integer values

    0 讨论(0)
  • 2020-12-05 13:07

    First get the text from edit text view

    edittext.getText().toString()
    

    and Store the obtained text in a string, say value.

    value = edittext.getText().toString()
    

    Then set value as the text for textview.

    textview.setText(value)
    
    0 讨论(0)
  • 2020-12-05 13:09
    EditText ein=(EditText)findViewById(R.id.edittext1);
    TextView t=new TextView(this);
    t.setText("Your Text is="+ein.getText());
    setContentView(t);
    
    0 讨论(0)
  • 2020-12-05 13:09

    First get the value from edit text in a String variable

    String value = edttxt.getText().toString();
    

    Then set that value to textView

    txtview.setText(value);
    

    Where edttxt refers to edit text field in XML file and txtview refers to textfield in XML file to show the value

    0 讨论(0)
  • 2020-12-05 13:12

    I'm just beginner to help you for getting edittext value to textview. Try out this code -

    EditText edit = (EditText)findViewById(R.id.editext1);
    TextView tview = (TextView)findViewById(R.id.textview1);
    String result = edit.getText().toString();
    tview.setText(result);
    

    This will get the text which is in EditText Hope this helps you.

    0 讨论(0)
  • 2020-12-05 13:12
    bb.setOnClickListener(
        new View.OnClickListener()
        {
            public void onClick(View view)
            {
                String s1=tt.getText().toString();
                tv.setText(s1);
            }
        }
    );
    
    0 讨论(0)
提交回复
热议问题