如何在另一个类的List中设置EditText?

时间:2014-07-26 11:44:00

标签: android eclipse

基本上我想要的是:当一个人回答"没有"单击按钮(否)我希望空文本视图更改为"为什么?"然后他们可以在edittext框中输入原因。然后最后一堂课可以列出所有问题。机器人。

 package com.toc.maintenance;

 import java.text.SimpleDateFormat;
 import java.util.Calendar;

 import android.annotation.SuppressLint;
 import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
 import android.view.View;
 import android.widget.Button;
 import android.widget.TextView;

 public class Safety extends Activity {
Button yes, No, NA, done;

TextView display;

@SuppressLint("SimpleDateFormat")
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.safety);
    No = (Button) findViewById(R.id.bNo);
    yes = (Button) findViewById(R.id.bYes);
    display = (TextView) findViewById(R.id.textView2);
    SimpleDateFormat dateFormat = new SimpleDateFormat(
            "yyyy/MM/dd HH:mm:ss");
    Calendar cal = Calendar.getInstance();
    String starttime = dateFormat.format(cal.getTime());

    Intent i = new Intent(getApplicationContext(), Report.class);
    i.putExtra("starttime", starttime);

    yes.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent Safety1 = new Intent(getApplicationContext(),
                    Safety1.class);
            startActivity(Safety1);

        }

    });
    NA = (Button) findViewById(R.id.bNA);

    NA.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent Safety1 = new Intent(getApplicationContext(),
                    Safety1.class);
            startActivity(Safety1);

        }
    });

    No.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            display.setText("Why?");
        }

    });
    done.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

 //here (at done button)is where I want to capture the editText for the final class 
 //"Report". I have an editBox with "@+id/explain" tag.  
 //But I am going to keep on adding text throughout the app. 
 //I've tried a setText, super, etc. But I just can't get it right. Thanks in advance.
        }

    });

}

}

2 个答案:

答案 0 :(得分:0)

如果你的意思是按课程进行,那么, 您可以使用EditTextInstance.getText(),然后您可以使用构造函数'将此返回的字符串传递给其他活动(通过intent.putExtra())或类'。

答案 1 :(得分:0)

使用putExtra()发送字符串“为什么?”或者其他的东西。使用getString();

检索它