2017-11-17 6 views
0

이 문제는 이메일 의도를 사용하는 기본 앱과 관련이 있습니다.사용자 입력에 따라 사용자 입력 업데이트

응용 프로그램 표시 4 개 입력의 UI :

  1. 이메일 주소
  2. 주제
  3. 이름
  4. 메시지
  5. 버튼

메시지가 textMultiLine 입력하다 유형.

메시지라는 기본 텍스트가 있습니다 "Hello CustomerName (This is a dynamic variable that would update as the user types their name in input number 3), could you please review our app..."

내가 뭘하려고 오전 실시간으로 업데이트하는 것입니다 그들은 입력 번호 3 (이름)에 입력으로 실제 고객 이름으로 CustomerName.

출처 :

package com.example.apit.testemailintent; 

import android.content.Intent; 
import android.os.Bundle; 
import android.support.design.widget.FloatingActionButton; 
import android.support.design.widget.Snackbar; 
import android.support.v7.app.AppCompatActivity; 
import android.support.v7.widget.Toolbar; 
import android.view.View; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.widget.Button; 
import android.widget.EditText; 

public class MainActivity extends AppCompatActivity { 

    EditText receiver, sub, mesg; 
    EditText customerName; 
    Button btn; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     receiver = (EditText) findViewById(R.id.email); 
     sub = (EditText) findViewById(R.id.subject); 
     customerName = (EditText) findViewById(R.id.name); 
     mesg = (EditText) findViewById(R.id.message); 
     btn = (Button) findViewById(R.id.submitButton); 

     addListenerOnButton1(); 

    } 

    public void addListenerOnButton1() { 
     btn.setOnClickListener(new View.OnClickListener() { 


      @Override 
      public void onClick(View view) { 

       String Sendto = receiver.getText().toString(); 
       String subject = sub.getText().toString(); 
       String cusName = customerName.getText().toString(); 
       String mesgs = "Hello " + cusName + ", could you please review our app...?"; 


       Intent email = new Intent(Intent.ACTION_SEND); 
       email.putExtra(Intent.EXTRA_EMAIL, new String[]{Sendto}); 
       email.putExtra(Intent.EXTRA_SUBJECT, subject); 
       email.putExtra(Intent.EXTRA_TEXT, mesgs); 

       email.setType("message/rfc822"); 
       startActivity(Intent.createChooser(email, "Please Choose an Email Client")); 

      } 
     }); 

    } 

} 

이 (Intent.EXTRA_TEXT mesgs를) 나는이 방법을 구현하는 경우

답변

1
nameEditText.addTextChangedListener(new TextWatcher() { 

    @Override 
    public void afterTextChanged(Editable s) {} 

    @Override 
    public void beforeTextChanged(CharSequence s, int start, 
    int count, int after) { 
    } 

    @Override 
    public void onTextChanged(CharSequence s, int start,int before, int count) { 
     messageEditText.setText("Hello " + s + " could you please review our app") 
    } 
    }); 
+0

, 어떻게 내가 email.putExtra에서 메시지 변수를 참조 할 수 있습니다 감사합니다; ? –

+0

문자열을 사용하여 onTextChanged charSequence를 저장하고이 문자열을 사용합니다. –

관련 문제