2012-05-07 3 views
0

이 질문을하는 데 바보 같지만 여러 EditText보기에서 UI 정보를 가져와 전자 메일 본문에 배치하는 방법을 찾을 수 없습니다. 참고 나는 의도를 가지고있다, 나는 단지 메시지 본문을 채우고 싶다.전자 메일 메시지 본문에 데이터를 추가하십시오.

Intent buildingfireemail = new Intent(android.content.Intent.ACTION_SEND); 
      buildingfireemail.setType("plain/text");///.setType("message/rfc822") 
      buildingfireemail.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"[email protected]"}); 
      buildingfireemail.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject"); 
      buildingfireemail.putExtra(android.content.Intent.EXTRA_TEXT, "Text" 
    //////////////I need to add data from 80+ views into here. 
    );try { 
       startActivity(Intent.createChooser(buildingfireemail, "Send mail...")); 
      } catch (android.content.ActivityNotFoundException ex) { 
       Toast.makeText(BuildingFireActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); 
      } 
+0

나는 이것에 초심자이고 나는 참고로 간다. – KyleM

+0

코드가 맞습니다. 이 코드로 무엇을 얻고 있습니까 ?? –

답변

1

모든 텍스트 편집에서 전체 문자열을 반환하는 함수를 만듭니다.

private String getText() { 
    String text = ""; 

    text += mEditText1.getText().toString() + "\n"; 
    text += mEditText2.getText().toString() + "\n"; 

    return text; 
} 

사용과 같은 : 클래스

buildingfireemail.putExtra(android.content.Intent.EXTRA_TEXT, getText()); 

초기화 멤버 변수 : 예를 들어

private EditText mEditText1; 

된 setContentView 후에서 onCreate에서 멤버 변수에 대한 모든 편집 텍스트를 가지고 :

mEditText1 = (EditText) findViewById(R.layout.editText1); 
+0

나는 정말로 새로운 것을 의미했다. . . 그 부분이 어디로 가는지, 내가 어떤 부분으로 바뀌 었는지 모르겠습니다. – KyleM

2

시도해보십시오. s :

Intent i = new Intent(Intent.ACTION_SEND); 
i.setType("text/plain"); 
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"[email protected]"}); 
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email"); 
i.putExtra(Intent.EXTRA_TEXT , editText.getText().toString()); 
try 
{ 
    startActivity(Intent.createChooser(i, "Send mail...")); 
} catch (android.content.ActivityNotFoundException ex) { 
Toast.makeText(MyActivity.this, "There are no email clients installed.",Toast.LENGTH_SHORT).show(); 
} 
관련 문제