有人可以帮我一个代码吗?我有一个联系表格,我希望您可以将表格连同联系表格的所有信息一起发送到 hotmail。如果您单击发送 (verzenden) 按钮,我想将表单发送到 serhildan_akdeniz@hotmail.com。
Java代码:
package com.MijnEersteApp;
import android.app.Activity;
import android.os.Bundle;
//import android.view.View;
import android.content.Intent;
//import android.widget.Button;
//import android.widget.AdapterView;
//import android.widget.AdapterView.OnItemSelectedListener;
//import android.widget.ArrayAdapter;
//import android.widget.Spinner;
//import android.widget.Toast;
import android.widget.EditText;
public class MijnEersteAppActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final EditText naamField = (EditText) findViewById(R.id.editTextNaam);
//String naam = naamField.getText().toString();
if(naamField.getText().toString().length()==0)
{
naamField.setError( "Vul uw naam in" );
}
final EditText mailField = (EditText) findViewById(R.id.editTextMail);
//String mail = mailField.getText().toString();
if(mailField.getText().toString().length()==0)
{
mailField.setError( "Vul uw email in" );
final EditText mobielField = (EditText) findViewById(R.id.editTextMobiel);
//String mobiel = mobielField.getText().toString();
if(mobielField.getText().toString().length() != 10)
{
mobielField.setError( "Vul een geldig telefoonnummer in" );
if(mobielField.getText().toString().length()==0)
{
mailField.setError("Vul uw telefoonnummer in");
final EditText berichtField = (EditText) findViewById(R.id.editTextBericht);
//String bericht = berichtField.getText().toString();
if(berichtField.getText().toString().length()==0)
{
berichtField.setError( "Vul uw bericht in" );
}
// final Spinner onderwerpSpinner = (Spinner) findViewById(R.id.SpinnerOnderwerpType);
//String onderwerpType = onderwerpSpinner.getSelectedItem().toString();
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{"serhildan_akdeniz@hotmail.com"});
email.putExtra(Intent.EXTRA_SUBJECT, "Klacht");
email.putExtra(Intent.EXTRA_TEXT, berichtField.getText());
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Serhildan"));
}
}
}
}
}
主要代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/contact" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/naam" />
<EditText
android:id="@+id/editTextNaam"
android:layout_width="wrap_content"
android:layout_height="26dp"
android:ems="10"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/mobiel" />
<EditText
android:id="@+id/editTextMobiel"
android:layout_width="wrap_content"
android:layout_height="26dp"
android:ems="10"
android:inputType="phone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/mail" />
<EditText
android:id="@+id/editTextMail"
android:layout_width="wrap_content"
android:layout_height="26dp"
android:ems="10"
android:inputType="textEmailAddress" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/onderwerp" />
<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/onderwerp_array"
android:prompt="@string/onderwerp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bericht" />
<EditText
android:id="@+id/editTextBericht"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:ems="10"
android:inputType="textMultiLine" />
<Button
android:id="@+id/buttonSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/verzenden"
/>
</LinearLayout>