Android 如何在不同类的列表中设置EditText?
基本上我想要的是:当一个人点击一个按钮回答“否”时,我希望空文本视图更改为“为什么?”?然后他们可以在编辑文本框中输入原因。最后一节课可以列出所有问题。安卓Android 如何在不同类的列表中设置EditText?,android,eclipse,Android,Eclipse,基本上我想要的是:当一个人点击一个按钮回答“否”时,我希望空文本视图更改为“为什么?”?然后他们可以在编辑文本框中输入原因。最后一节课可以列出所有问题。安卓 package com.toc.maintenance; import java.text.SimpleDateFormat; import java.util.Calendar; import android.annotation.SuppressLint; import android.app.Activity; imp
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.
}
});
}
}如果你指的是课堂活动,
您可以使用EditTextInstance.getText,然后可以通过intent.putExtra或类“using constructor”将返回的字符串传递给其他Activity 使用putExtra发送字符串为什么?或者别的什么。使用getString检索它 最后使用了“是”或“否”按钮,然后在按下按钮时使用.setText。变得容易多了。