0
この問題は電子メールの意図を利用する基本的なアプリケーションに関連しています。入力時にユーザー入力を更新する
4つの入力アプリディスプレイのUI:
- メールアドレス
- 件名メッセージが
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"));
}
});
}
}
は、私は、このメソッドを実装する場合、どのように私はemail.putExtra(Intent.EXTRA_TEXT、mesgs)にメッセージ変数を参照することができ、
をいただき、ありがとうございます。 ? –
文字列を使用してonTextChanged charSequenceを格納し、このStringを使用します。 –