how to add new line to email contents?

后端 未结 3 1690
暗喜
暗喜 2020-12-11 07:42

I want to Place content like

  1. Name
  2. Pass
  3. Email

to the email content. how to do this...?

I tried this but not working.

相关标签:
3条回答
  • 2020-12-11 07:57

    Why not use a StringBuilder to create all your content and then add it to your intent ?

    StringBuilder sb;
    
    sb.append("First Name : ");
    sb.append(fname.getText().toString());
    sb.append('\n');
    sb.append("Last Name : ");
    sb.append(lname.getText().toString());
    sb.append('\n');
    sb.append("Email : ");
    sb.append(email.getText().toString());
    
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,sb);
    
    0 讨论(0)
  • 2020-12-11 08:02

    You can simply do like this

    String output = "FirstName :\nLastName :\nEmail ";
    

    and add the string to the email content:

    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, output);
    
    0 讨论(0)
  • 2020-12-11 08:04

    Create a single String containing everything including "\n" for every line-break.

    StringBuilder emailBody = new StringBuilder("First Name : ");
    emailBody.append(fname.getText()).append("\n");
    emailBody.append("Last Name : ").append(lname.getText()).append("\n");
    emailBody.append("Email : ").append(email.getText());
    emailIntent.putExtra(Intent.EXTRA_TEXT   , emailBody.toString());
    
    0 讨论(0)
提交回复
热议问题