fourth.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/refill"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/refill"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/rxnumber"
android:text="Rx#: "
android:layout_height="fill_parent"
android:layout_width="wrap_content"
/>
<EditText
android:id="@+id/rxnumberfill"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/firstname"
android:text="First Name: "
android:layout_height="fill_parent"
android:layout_width="wrap_content"
/>
<EditText
android:id="@+id/firstnamefill"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/lastname"
android:text="Last Name: "
android:layout_height="fill_parent"
android:layout_width="wrap_content"
/>
<EditText
android:id="@+id/lastnamefill"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/dob"
android:text="Date of Birth: "
android:layout_height="fill_parent"
android:layout_width="wrap_content"
/>
<EditText
android:id="@+id/dob"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/phoneNumber"
android:text="Phone Number: "
android:layout_height="fill_parent"
android:layout_width="wrap_content"
/>
<EditText
android:id="@+id/phoneNumberfill"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
</LinearLayout>
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/send1"
android:text="@string/send1"/>
</LinearLayout>
FourthAct.java
package app.belmont.pharmacy;
import android.app.Activity;
import android.os.Bundle; //onCreate만들기
import android.view.View;//리스너만들기
import android.content.Intent;//인텐트만들기\
import android.widget.Button;
import android.widget.EditText;
public class FourthAct extends Activity {
EditText rxnumberfill,firstnamefill,lastnamefill,dob,phoneNumberfill;
Button send1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.fourth);
rxnumberfill = (EditText)findViewById(R.id.rxnumberfill);
firstnamefill =(EditText)findViewById(R.id.firstnamefill);
lastnamefill = (EditText)findViewById(R.id.lastnamefill);
dob = (EditText)findViewById(R.id.dob);
phoneNumberfill = (EditText)findViewById(R.id.phoneNumberfill);
Button send1 = (Button)this.findViewById(R.id.send1);
String rxnumber = rxnumberfill.getText().toString();
String firstname = firstnamefill.getText().toString();
String lastname = lastnamefill.getText().toString();
String dateofbirth = dob.getText().toString();
String phoneNumber = phoneNumberfill.getText().toString();
send1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
sendEmailOrMessage();
}
});
}
void sendEmailOrMessage() {
Intent i=new Intent(Intent.ACTION_SEND);
i.addCategory(Intent.CATEGORY_DEFAULT);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_SUBJECT, "EXTRA_SUBJECT");
i.putExtra(Intent.EXTRA_TEXT1, rxnumber);
i.putExtra(Intent.EXTRA_TEXT2, firstname);
i.putExtra(Intent.EXTRA_TEXT3, lastname);
i.putExtra(Intent.EXTRA_TEXT4, dateofbirth);
i.putExtra(Intent.EXTRA_TEXT5, phoneNumber);
i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"topaz4762@hotmail.com"});
i.putExtra(Intent.EXTRA_CC, new String[]{"rxminnie@hotmail.com"});
startActivity(Intent.createChooser(i, "Refill Request"));
}
};
fourth.xml의 editText박스에 입력된 내용을 getText().toString();을 이용해 string id를 부여했구요.
에러가 나는 부분이,
i.putExtra(Intent.EXTRA_TEXT, rxnumber);
i.putExtra(Intent.EXTRA_TEXT2, firstname);
i.putExtra(Intent.EXTRA_TEXT3, lastname);
i.putExtra(Intent.EXTRA_TEXT4, dateofbirth);
i.putExtra(Intent.EXTRA_TEXT5, phoneNumber);
요부분인데요,
i.putExtra(Intent.EXTRA_TEXT, getString(R.id.rxnumber)); 이런식으로 바꾸어도 읽히지가 않네요.
도와주세요.