How to add text to editext

前端 未结 5 1056
旧巷少年郎
旧巷少年郎 2021-01-05 13:03

I\'ve got a problem with populating an edittext. Using the following code i can set the text just fine, however what i am trying to do is add to the edittext. For example th

相关标签:
5条回答
  • 2021-01-05 13:16
    String title = bundle.getString("number1");
    EditText editText = (EditText) findViewById(R.id.editText1);
    editText.setText(editText.getText().toString() + title);
    
    0 讨论(0)
  • 2021-01-05 13:24

    Should be as simple as:

    editText.setText("hello");
    

    In your code:

    EditText editText=(EditText)findViewById(R.id.x);
    editText.setText("hello");
    
    0 讨论(0)
  • 2021-01-05 13:26

    try this code

    String title = bundle.getString("number1");
    EditText editText = (EditText) findViewById(R.id.editText1);
    editText.append(title);
    

    if you want to set the only new value use this

    editText.setText(title);
    
    0 讨论(0)
  • 2021-01-05 13:42

    You'd need editText.setText(editText.getText() + "string");.

    EditText et = (EditText) findViewById(R.id.editText1);
    et.setText(et.getText() + title);
    
    0 讨论(0)
  • 2021-01-05 13:42

    Set edit text to the previuos value plus the new value.

    EditText et = (EditText) findViewById(R.id.editText1);
    et.setText(et.GetText() + title);
    
    0 讨论(0)
提交回复
热议问题