我有一个包含各种字符串和数字的大表,其中一些必须是可编辑的。该表是从具有getter和setter的对象加载的。
我想用编辑文本和ok按钮创建一个通用输入屏幕;并使用它来编辑字段。但是,我无法让它工作,这是我的代码片段:
public class InputViewController extends Activity {
private String inputType;
EditText mEdit;
private String inputString;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.inputscreen);
Bundle extras=getIntent().getExtras();
{
//get the type of input from the screen that sent us here, contained in a putextra
inputType = extras.getString("inputType");
TextView textViewInput = (TextView) findViewById(R.id.textViewInput);
textViewInput.setText(inputType);
mEdit = (EditText)findViewById(R.id.editText1);
}
//save input and return to previous screen
final Button button = (Button) findViewById(R.id.button3);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//save input based on inputType
if(inputType.equals("Oplossing")){
inputString = mEdit.getText().toString();
ActivityViewController.activityObject.setSolution(inputString);
System.out.println(ActivityViewController.activityObject.getSolution());
}
//return to previous screen
finish();
}
});