I currently have three buttons, one is for Update, which allows the title to be updated. Delete, which allows the database entry to be deleted. These currently work fine.
I have added a third button called Complete (completeBtn). When the user presses the Complete button i would like the EditText (titleText) to be changed to "Marked Complete" and the title entry to be changed in the database. I think i am pretty close, but not sure what the problem is.
There is currently no error being show, but when i press the Complete button it does not change the EditText for titleText to "Marked Complete" or change the value for title stored in the database to "Marked Complete"
Any help would be appreciated. :)
ModifyDeadlines.java
package com.example.pc.achieve;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class ModifyDeadline extends Activity implements OnClickListener {
private EditText titleText;
private Button updateBtn, completeBtn, deleteBtn;
private EditText descText;
private long _id;
private DBManager dbManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Modify Record");
setContentView(R.layout.activity_modify_record);
dbManager = new DBManager(this);
dbManager.open();
titleText = (EditText) findViewById(R.id.subject_edittext);
descText = (EditText) findViewById(R.id.description_edittext);
updateBtn = (Button) findViewById(R.id.btn_update);
deleteBtn = (Button) findViewById(R.id.btn_delete);
completeBtn = (Button) findViewById(R.id.btn_complete);
titleText.setText( "Marked Complete" + completeBtn.getText() );
Intent intent = getIntent();
String id = intent.getStringExtra("id");
String name = intent.getStringExtra("title");
String desc = intent.getStringExtra("desc");
_id = Long.parseLong(id);
titleText.setText(name);
descText.setText(desc);
updateBtn.setOnClickListener(this);
deleteBtn.setOnClickListener(this);
completeBtn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_update:
case R.id.btn_complete:
String title = titleText.getText().toString();
String desc = descText.getText().toString();
dbManager.update(_id, title, desc);
this.returnHome();
break;
case R.id.btn_delete:
dbManager.delete(_id);
this.returnHome();
break;
}
}
public void returnHome() {
Intent home_intent = new Intent(getApplicationContext(), ViewDeadlines.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(home_intent);
}
}
TextViewcan be updated viasettextmethod. But on your button click, you do not call this method to update the value.