机器人发送使用电子邮件地址的列表的电子邮件 [英] Android Sending an email using a list of email addresses

查看:382
本文介绍了机器人发送使用电子邮件地址的列表的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建内置在此刻形式的应用程序被发送到一个pre坚定的电子邮件地址。而不是制造这取决于电子邮件地址的应用程序十几版本将其发送到有没有一种方式,它可以自动将取决于人们preSS形式的电子邮件地址?即在滚动条点击美国和它会自动把美国的电子邮件地址的电子邮件发送?

如果那么有没有一个教程或例子,任何人都可以点我?

我重视我下面的code:

 进口java.util.Calendar中;
进口android.app.Activity;
进口android.app.DatePickerDialog;
进口android.app.Dialog;
进口android.content.Intent;
进口android.os.Bundle;
进口android.view.View;
进口android.view.View.OnClickListener;
进口android.widget.Button;
进口android.widget.CheckBox;
进口android.widget.DatePicker;
进口android.widget.EditText;
进口android.widget.Spinner;
进口android.widget.TextView;
公共类NearMiss延伸活动{    按钮发送;
    受保护的静态最终诠释CAMERA_PIC_REQUEST = 0;
    私人TextView的tvDisplayDate;    私人按钮btnChangeDate;
    私人诠释年;
    私人诠释月;
    私人诠释天;
    静态最终诠释DATE_DIALOG_ID = 999;    / **当第一次创建活动调用。 * /
    @覆盖
    公共无效的onCreate(捆绑savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.nearmiss);        按钮相机=(按钮)findViewById(R.id.button2);
        camera.setOnClickListener(新View.OnClickListener(){
            公共无效的onClick(查看视图){
                意图cameraIntent =新意图(android.provider.MediaStore.ACTION_IM​​AGE_CAPTURE);
                  startActivityForResult(cameraIntent,CAMERA_PIC_REQUEST);
    ;                }
            });        setCurrentDateOnView();
        addListenerOnButton();
    }
    //显示当前日期
        公共无效setCurrentDateOnView(){
            tvDisplayDate =(的TextView)findViewById(R.id.EditTextDate);            最后的日历C = Calendar.getInstance();
            年= c.get(Calendar.YEAR);
            月= c.get(的Calendar.MONTH);
            天= c.get(Calendar.DAY_OF_MONTH);
            //将当前日期到的TextView
            tvDisplayDate.setText(新的StringBuilder()
                    //月份是基于0,只需添加1
                    .append(天).append( - )。追加(月+ 1).append( - )
                    .append(年).append());        }
        公共无效addListenerOnButton(){
            btnChangeDate =(按钮)findViewById(R.id.btnChangeDate);
            btnChangeDate.setOnClickListener(新OnClickListener(){
                @覆盖
                公共无效的onClick(视图v){
                    的ShowDialog(DATE_DIALOG_ID);
                }
            });
        }
        @覆盖
        保护对话框onCreateDialog(INT ID){
            开关(ID){
            案例DATE_DIALOG_ID:
                //设置日期选择器为当前日期
                返回新DatePickerDialog(这一点,datePickerListener,年,月,
                        天);
            }
            返回null;
        }
        私人DatePickerDialog.OnDateSetListener datePickerListener =新DatePickerDialog.OnDateSetListener(){
            //当关闭对话框,下面的方法将被调用。
            公共无效onDateSet(查看的DatePicker,诠释selectedYear,
                    INT selectedMonth,诠释selectedDay){
                年= selectedYear;
                月= selectedMonth;
                天= selectedDay;
                //组选定的日期到的TextView
                tvDisplayDate.setText(新的StringBuilder()。追加(天)
                        .append( - )。追加(月+ 1).append( - )。追加(年)
                        .append());            }
        };    公共无效sendFeedback(查看按钮){        最终的EditText名称字段=(EditText上)findViewById(R.id.EditTextName);
        字符串名称= nameField.getText()的toString()。        最终的EditText emailField =(EditText上)findViewById(R.id.EditTextEmail);
        。字符串email = emailField.getText()的toString();        最终的EditText feedbackField =(EditText上)findViewById(R.id.EditTextFeedbackBody);
        字符串的反馈= feedbackField.getText()的toString()。        最后的微调feedbackSpinner =(微调)findViewById(R.id.SpinnerFeedbackType);
        。字符串feedbackType = feedbackSpinner.getSelectedItem()的toString();        最终的EditText的DateField =(EditText上)findViewById(R.id.EditTextDate);
        。字符串日期= dateField.getText()的toString();
        最终的EditText timeField =(EditText上)findViewById(R.id.EditTextTime);
        字符串时间= timeField.getText()的toString()。        最后的微调feedbackLocation =(微调)findViewById(R.id.SpinnerLocationType);
        。字符串的locationType = feedbackLocation.getSelectedItem()的toString();        最终的EditText contactField =(EditText上)findViewById(R.id.EditTextContact);
        弦接触= contactField.getText()的toString()。        最后的微调feedbackOperative =(微调)findViewById(R.id.SpinnerOperativeType);
        。字符串operativeType = feedbackOperative.getSelectedItem()的toString();        最后复选框responseCheckbox =(复选框)findViewById(R.id.C​​heckBoxResponse);
        布尔bRequiresResponse = responseCheckbox.isChecked();
        //取的字段和格式化消息内容
        字符串主题= formatFeedbackSubject(feedbackType);
        字符串消息= formatFeedbackMessage(feedbackType,姓名,
             电子邮件,反馈,日期,时间,的locationType,operativeType,bRequiresResponse,联系方式);        //创建消息
        sendFeedbackMessage(主题,邮件);
    }    保护字符串formatFeedbackSubject(字符串feedbackType){        字符串strFeedbackSubjectFormat = getResources()。的getString(
                R.string.feedbackmessagesubject_format);
        字符串strFeedbackSubject =的String.format(strFeedbackSubjectFormat,feedbackType);        返回strFeedbackSubject;
    }    保护字符串formatFeedbackMessage(字符串feedbackType,字符串名称,
            字符串email,字符串反馈,字符串日期,字符串时间,字符串的locationType,字符串operativeType,布尔bR​​equiresResponse,弦接触){        字符串strFeedbackFormatMsg = getResources()。的getString(
                R.string.feedbackmessagebody_format);
        字符串strRequiresResponse = getResponseString(bRequiresResponse);
        字符串strFeedbackMsg =的String.format(strFeedbackFormatMsg,
                姓名,电子邮件,日期,时间,feedbackType,反馈的locationType,operativeType,strRequiresResponse,联系方式);        返回strFeedbackMsg;
    }    保护字符串getResponseString(布尔bRequiresResponse)
    {
        如果(bRequiresResponse ==真)
        {
            返回getResources()的getString(R.string.feedbackmessagebody_responseyes)。
        }其他{
            返回getResources()的getString(R.string.feedbackmessagebody_responseno)。
        }    }
    公共无效sendFeedbackMessage(字符串主题,字符串消息){
        意图messageIntent =新意图(android.content.Intent.ACTION_SEND);
        字符串aEmailList [] = {uk@abc.com,usa@abc.com};
        messageIntent.putExtra(android.content.Intent.EXTRA_EMAIL,aEmailList);
        messageIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,学科);
        messageIntent.setType(纯/文);
        messageIntent.putExtra(android.content.Intent.EXTRA_TEXT,消息);
        startActivity(messageIntent);
    }
}

和.xml文件:

 <?XML版本=1.0编码=UTF-8&GT?;
<滚动型
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID / ScrollView01
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:滚动条=垂直>    <的LinearLayout
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:背景=@绘制/ mainscreenc
        机器人:方向=垂直>        <的TableRow
            机器人:ID =@ + ID / tableRow1
            机器人:layout_width =match_parent
            机器人:layout_height =125dip
            机器人:背景=@绘制/标题>        < /&的TableRow GT;        <的EditText
            机器人:ID =@ + ID / EditTextName
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginTop =15dip
            机器人:提示=@字符串/ feedbackname
            安卓的inputType =textPersonName
            机器人:文字颜色=@色/红色>
< /&的EditText GT;        <的EditText
            机器人:ID =@ + ID / EditTextEmail
            机器人:layout_height =WRAP_CONTENT
            机器人:提示=@字符串/ feedbackemail
            安卓的inputType =textEmailAddress
            机器人:layout_width =FILL_PARENT
            机器人:文字颜色=@色/红色>< /&的EditText GT;        <的TextView
            机器人:ID =@ + ID / textView1
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =10dip
            机器人:layout_marginTop =20dip
            机器人:文字=近小姐类别:
            机器人:textAppearance =机器人:ATTR / textAppearanceMedium
            机器人:文字颜色=@彩色/黑白/>        <微调
            机器人:ID =@ + ID / SpinnerFeedbackType
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginTop =5dip
            机器人:项=@阵列/ feedbacktypelist
            机器人:提示=@字符串/ feedbacktitle
            机器人:文字颜色=@色/红色>
< /微调>        <的EditText
            机器人:ID =@ + ID / EditTextFeedbackBody
            机器人:layout_height =WRAP_CONTENT
            机器人:提示=@字符串/ feedbackbody
            安卓的inputType =textMultiLine
            机器人:行=5
            机器人:layout_width =FILL_PARENT
            机器人:文字颜色=@色/红色>< /&的EditText GT;        <的TextView
            机器人:ID =@ + ID / textView3
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =10dip
            机器人:layout_marginTop =20dip
            机器人:文字=近小姐日期:
            机器人:textAppearance =机器人:ATTR / textAppearanceMedium
            机器人:文字颜色=@彩色/黑白/>    <的EditText
            机器人:ID =@ + ID / EditTextDate
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:提示=近小姐的大致日期
            机器人:文字颜色=@色/红色>
            < /&的EditText GT;    <按钮
        机器人:ID =@ + ID / btnChangeDate
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginBottom =10dip
        机器人:文本=更改日期/>        <的EditText
            机器人:ID =@ + ID / EditTextTime
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:提示=近小姐的大致时间
            机器人:文字颜色=@色/红色>        < /&的EditText GT;        <的TextView
            机器人:ID =@ + ID / textView2
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =10dip
            机器人:layout_marginTop =20dip
            机器人:文字=地点附近的小姐:
            机器人:textAppearance =机器人:ATTR / textAppearanceMedium
            机器人:文字颜色=@彩色/黑白/>        <微调
            机器人:ID =@ + ID / SpinnerLocationType
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginTop =5dip
            机器人:项=@阵列/ locationtypelist
            机器人:提示=@字符串/ locationtitle
            机器人:文字颜色=@色/红色>
< /微调>         <的TextView
             机器人:ID =@ + ID / textView2
             机器人:layout_width =WRAP_CONTENT
             机器人:layout_height =WRAP_CONTENT
             机器人:layout_marginLeft =10dip
             机器人:文字=你的主要办公室:
             机器人:textAppearance =机器人:ATTR / textAppearanceMedium
             机器人:文字颜色=@彩色/黑白/>        <微调
            机器人:ID =@ + ID / SpinnerOperativeType
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginTop =5dip
            机器人:项=@阵列/ operativetypelist
            机器人:提示=@字符串/ officetitle
            机器人:文字颜色=@色/红色>
< /微调>        <复选框
            机器人:ID =@ + ID / CheckBoxResponse
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginTop =15dip
            机器人:文字=@字符串/ feedbackresponse
            机器人:文字颜色=@彩色/黑白>
< /复选框>        <的EditText
            机器人:ID =@ + ID / EditTextContact
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:提示=联系电话
            机器人:文字颜色=@色/红色>        < /&的EditText GT;        <按钮
            机器人:ID =@ + ID /按钮2
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =10dip
            机器人:layout_marginTop =10dip
            机器人:文字=拍摄照片/>        <按钮
            机器人:ID =@ + ID / ButtonSendFeedback
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginBottom =15dip
            机器人:layout_marginTop =15dip
            安卓的onClick =sendFeedback
            机器人:文字=@字符串/ feedbackbutton>
< /按钮>
    < / LinearLayout中>
< /滚动型>

非常感谢


解决方案

您可以通过键值对实施微调实现

  valueTextView =(的TextView)findViewById(R.id.selected);
   微调S =(微调)findViewById(R.id.spinner);
    最后迈德特项目[] =新迈德特[3];
    项目[0] =新迈德特(美国,us@abc.com);
    项目[1] =新迈德特(印度,india@abc.com);
    项目[2] =新迈德特(UK,uk@abc.com);
    ArrayAdapter<&迈德特GT;适配器=新ArrayAdapter<迈德特>这,android.R.layout.simple_spinner_item,项目);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    s.setAdapter(适配器);
    s.setOnItemSelectedListener(新AdapterView.OnItemSelectedListener()
     {
            公共无效onItemSelected(适配器视图<>母公司,观景,INT位置,长的ID)
            {
                迈德特D =项目[位置]
                valueTextView.setText(d.getValue());
            }            公共无效onNothingSelected(适配器视图<>母公司)
            {
            }
        }
    );
   迈德特类{
    公共迈德特(字符串spinnerText,字符串值){
        this.spinnerText = spinnerText;
        THIS.VALUE =价值;
    }    公共字符串getSpinnerText(){
        返回spinnerText;
    }    公共字符串的getValue(){
        返回值;
    }    公共字符串的toString(){
        返回spinnerText;
    }    串spinnerText;
    字符串值;
}

I have created an app with a form built in that at the moment is being sent to a pre determined email address. Rather than create a dozen versions of the app depending on what email address to send it to is there a way that it can automatically add an email address depending on what people press in the form? i.e click on the US in the scroll bar and it will automatically put the US email address in the email to send?

If so is there an tutorial or examples that anyone can point me to?

I Have attached my code below:

import java.util.Calendar;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
public class NearMiss extends Activity {

    Button send;
    protected static final int CAMERA_PIC_REQUEST = 0;
    private TextView tvDisplayDate;

    private Button btnChangeDate;


    private int year;
    private int month;
    private int day;


    static final int DATE_DIALOG_ID = 999;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.nearmiss);

        Button camera = (Button) findViewById(R.id.button2); 
        camera.setOnClickListener(new View.OnClickListener() { 
            public void onClick(View view) {
                Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                  startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);  
    ;

                }     
            });  



        setCurrentDateOnView();
        addListenerOnButton();


    }


    // display current date
        public void setCurrentDateOnView() {
            tvDisplayDate = (TextView) findViewById(R.id.EditTextDate);

            final Calendar c = Calendar.getInstance();
            year = c.get(Calendar.YEAR);
            month = c.get(Calendar.MONTH);
            day = c.get(Calendar.DAY_OF_MONTH);
            // set current date into textview
            tvDisplayDate.setText(new StringBuilder()
                    // Month is 0 based, just add 1
                    .append(day).append("-").append(month + 1).append("-")
                    .append(year).append(" "));

        }
        public void addListenerOnButton() {
            btnChangeDate = (Button) findViewById(R.id.btnChangeDate);
            btnChangeDate.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    showDialog(DATE_DIALOG_ID);
                }
            });
        }
        @Override
        protected Dialog onCreateDialog(int id) {
            switch (id) {
            case DATE_DIALOG_ID:
                // set date picker as current date
                return new DatePickerDialog(this, datePickerListener, year, month,
                        day);
            }
            return null;
        }
        private DatePickerDialog.OnDateSetListener datePickerListener = new DatePickerDialog.OnDateSetListener() {
            // when dialog box is closed, below method will be called.
            public void onDateSet(DatePicker view, int selectedYear,
                    int selectedMonth, int selectedDay) {
                year = selectedYear;
                month = selectedMonth;
                day = selectedDay;
                // set selected date into textview
                tvDisplayDate.setText(new StringBuilder().append(day)
                        .append("-").append(month + 1).append("-").append(year)
                        .append(" "));

            }
        };



    public void sendFeedback(View button) {

        final EditText nameField = (EditText) findViewById(R.id.EditTextName);
        String name = nameField.getText().toString();

        final EditText emailField = (EditText) findViewById(R.id.EditTextEmail);
        String email = emailField.getText().toString();

        final EditText feedbackField = (EditText) findViewById(R.id.EditTextFeedbackBody);
        String feedback = feedbackField.getText().toString();

        final Spinner feedbackSpinner = (Spinner) findViewById(R.id.SpinnerFeedbackType);
        String feedbackType = feedbackSpinner.getSelectedItem().toString();

        final EditText dateField = (EditText) findViewById(R.id.EditTextDate);
        String date = dateField.getText().toString();
        final EditText timeField = (EditText) findViewById(R.id.EditTextTime);
        String time = timeField.getText().toString();

        final Spinner feedbackLocation = (Spinner) findViewById(R.id.SpinnerLocationType);
        String locationType = feedbackLocation.getSelectedItem().toString();

        final EditText contactField = (EditText) findViewById(R.id.EditTextContact);
        String contact = contactField.getText().toString();

        final Spinner feedbackOperative = (Spinner) findViewById(R.id.SpinnerOperativeType);
        String operativeType = feedbackOperative.getSelectedItem().toString();

        final CheckBox responseCheckbox = (CheckBox) findViewById(R.id.CheckBoxResponse);
        boolean bRequiresResponse = responseCheckbox.isChecked();


        // Take the fields and format the message contents
        String subject = formatFeedbackSubject(feedbackType);
        String message = formatFeedbackMessage(feedbackType, name,
             email, feedback, date, time, locationType, operativeType, bRequiresResponse, contact);

        // Create the message
        sendFeedbackMessage(subject, message);
    }

    protected String formatFeedbackSubject(String feedbackType) {

        String strFeedbackSubjectFormat = getResources().getString(
                R.string.feedbackmessagesubject_format);
        String strFeedbackSubject = String.format(strFeedbackSubjectFormat, feedbackType);

        return strFeedbackSubject;
    }

    protected String formatFeedbackMessage(String feedbackType, String name,
            String email, String feedback, String date, String time, String locationType, String operativeType, boolean bRequiresResponse, String contact) {

        String strFeedbackFormatMsg = getResources().getString(
                R.string.feedbackmessagebody_format);
        String strRequiresResponse = getResponseString(bRequiresResponse);
        String strFeedbackMsg = String.format(strFeedbackFormatMsg,
                name, email, date, time, feedbackType, feedback, locationType, operativeType, strRequiresResponse, contact);

        return strFeedbackMsg;
    }

    protected String getResponseString(boolean bRequiresResponse)
    {
        if(bRequiresResponse==true)
        {
            return getResources().getString(R.string.feedbackmessagebody_responseyes);
        } else {
            return getResources().getString(R.string.feedbackmessagebody_responseno);
        }

    }
    public void sendFeedbackMessage(String subject, String message) {
        Intent messageIntent = new Intent(android.content.Intent.ACTION_SEND);
        String aEmailList[] = { "uk@abc.com", "usa@abc.com" };
        messageIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
        messageIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
        messageIntent.setType("plain/text");
        messageIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
        startActivity(messageIntent);




    }
} 

And the .xml file:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ScrollView01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scrollbars="vertical">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/mainscreenc"
        android:orientation="vertical" >

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="match_parent"
            android:layout_height="125dip"
            android:background="@drawable/title" >

        </TableRow>

        <EditText
            android:id="@+id/EditTextName"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="15dip"
            android:hint="@string/feedbackname"
            android:inputType="textPersonName"
            android:textColor="@color/red" >
</EditText>

        <EditText
            android:id="@+id/EditTextEmail"
            android:layout_height="wrap_content"
            android:hint="@string/feedbackemail"
            android:inputType="textEmailAddress"
            android:layout_width="fill_parent"
            android:textColor="@color/red" ></EditText>

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"
            android:layout_marginTop="20dip"
            android:text="Category of Near Miss:"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@color/black" />

        <Spinner
            android:id="@+id/SpinnerFeedbackType"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dip"
            android:entries="@array/feedbacktypelist"
            android:prompt="@string/feedbacktitle" 
            android:textColor="@color/red" >
</Spinner>

        <EditText
            android:id="@+id/EditTextFeedbackBody"
            android:layout_height="wrap_content"
            android:hint="@string/feedbackbody"
            android:inputType="textMultiLine"
            android:lines="5"
            android:layout_width="fill_parent"
            android:textColor="@color/red" ></EditText>

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"
            android:layout_marginTop="20dip"
            android:text="Date of Near Miss:" 
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@color/black" />

    <EditText
            android:id="@+id/EditTextDate"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="Approximate Date of Near Miss" 
            android:textColor="@color/red" >
            </EditText>

    <Button
        android:id="@+id/btnChangeDate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dip"
        android:text="Change Date" />

        <EditText
            android:id="@+id/EditTextTime"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="Approximate Time of Near Miss" 
            android:textColor="@color/red" >

        </EditText>

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"
            android:layout_marginTop="20dip"
            android:text="Location Of Near Miss:"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@color/black" />

        <Spinner
            android:id="@+id/SpinnerLocationType"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dip"
            android:entries="@array/locationtypelist"
            android:prompt="@string/locationtitle"  
            android:textColor="@color/red" >
</Spinner>

         <TextView
             android:id="@+id/textView2"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginLeft="10dip"
             android:text="Your Main Office:"
             android:textAppearance="?android:attr/textAppearanceMedium"
             android:textColor="@color/black" />

        <Spinner
            android:id="@+id/SpinnerOperativeType"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dip"
            android:entries="@array/operativetypelist"
            android:prompt="@string/officetitle"  
            android:textColor="@color/red" >
</Spinner>

        <CheckBox
            android:id="@+id/CheckBoxResponse"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="15dip"
            android:text="@string/feedbackresponse"
            android:textColor="@color/black" >
</CheckBox>

        <EditText
            android:id="@+id/EditTextContact"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="Contact Number" 
            android:textColor="@color/red" >

        </EditText>

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"
            android:layout_marginTop="10dip"
            android:text="Take Photo" />

        <Button
            android:id="@+id/ButtonSendFeedback"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="15dip"
            android:layout_marginTop="15dip"
            android:onClick="sendFeedback"
            android:text="@string/feedbackbutton" >
</Button>


    </LinearLayout>
</ScrollView>

Many Thanks

解决方案

You can achieve by implementing Spinner with Key-Value Pairs

  valueTextView = (TextView)findViewById( R.id.selected );
   Spinner s = (Spinner)findViewById(R.id.spinner);
    final MyData items[] = new MyData[3];
    items[0] = new MyData( "US","us@abc.com" );
    items[1] = new MyData( "INDIA","india@abc.com" );
    items[2] = new MyData( "UK","uk@abc.com" );
    ArrayAdapter<MyData> adapter = new ArrayAdapter<MyData>this,android.R.layout.simple_spinner_item,items);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    s.setAdapter(adapter);
    s.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() 
     {
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) 
            {
                MyData d = items[position];
                valueTextView.setText( d.getValue() );
            }

            public void onNothingSelected(AdapterView<?> parent) 
            {
            }
        }
    );


   class MyData {
    public MyData( String spinnerText, String value ) {
        this.spinnerText = spinnerText;
        this.value = value;
    }

    public String getSpinnerText() {
        return spinnerText;
    }

    public String getValue() {
        return value;
    }

    public String toString() {
        return spinnerText;
    }

    String spinnerText;
    String value;
}

这篇关于机器人发送使用电子邮件地址的列表的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆