@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_log);
mLayout = (LinearLayout) findViewById(R.id.linear_layout_logbook);
max_bpm = (EditText) findViewById(R.id.dL_max_heartrate);
min_bpm = (EditText) findViewById(R.id.dL_min_bpm);
avg_speed = (EditText) findViewById(R.id.dL_Average_Speed);
date = (EditText) findViewById(R.id.dL_date);
}
public void OnClick(View v) {
max_bpm_in = max_bpm.getText().toString();
min_bpm_in = min_bpm.getText().toString();
avg_speed_in = avg_speed.getText().toString();
date_in = date.getText().toString();
mLayout.addView(createNewTextView(max_bpm_in,min_bpm_in,avg_speed_in,date_in));
}
private TextView createNewTextView(String max_bpm, String min_bpm, String avg_speed, String date) {
final ActionBar.LayoutParams lparams = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT);
final TextView textView = new TextView(this);
textView.setLayoutParams(lparams);
textView.setText("Date: " + date + "\nMaximum Heat Rate: " + max_bpm + "\nMinimum Heart Rate: " + min_bpm + "\nAverage Speed: " + avg_speed);
return textView;
}
As you can see I wish to take the information from certain edittexts and then create a textview in a new activity using the information inputted into the text views. I want to do this is such a way that new text views can be added with every button click as the information is going to displayed a log.
The application crashes upon the button press which uses Android:onClick in the xml.
Is there something I am missing?