嗨!如何存储字段并在不同的活动上显示结果?请

时间:2014-04-19 17:29:44

标签: android string android-intent android-button

我希望用户输入的字段在新活动中显示为studentnoText和courseField的列表视图。

public class Student extends Activity {

    private String totalStudents [];

    private EditText studentnoText;
    private EditText studentnameText;
    private EditText courseField;
    private Spinner departmentSpinner;
    private EditText dobField;
    private Button registerButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_student);

    studentnoText = (EditText) findViewById(R.id.studentnoText);
    studentnameText = (EditText) findViewById(R.id.studentnameText);
    dobField = (EditText) findViewById(R.id.dobField);
    courseField = (EditText) findViewById(R.id.courseField);
    departmentSpinner = (Spinner) findViewById(R.id.departmentSpinner);
    registerButton = (Button) findViewById(R.id.registerButton);

}

    public void registerButtonPressed (View view){




        Log.v("Register","Register Pressed!");
    }

}

1 个答案:

答案 0 :(得分:0)

使用额外发送数据

mIntent.putExtra("TEXT", studentnoText.gettext().toString());
mIntent.putExtra("TEXT_1", studentName.gettext().toString());

使用额外获取数据

String strNO,strName;
strNO= extras.getString("TEXT");
strName = extras.getString("TEXT_1");