I have a TableLayout that contain 60 TextView. The TextViews have an onClick method for input inside them string and background color. When i input one TextView i need to store it into a Sqlite table and for recognize which TextView has changed i need to store the Row and Column of the clicked TextView. I need to save the changed TextView into sqlite so the user can find and can add new changed TextView inside table. How can i do that?
ActivityforResult that take back the inputed data:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == 1) {
if (resultCode == RESULT_OK) {
MySQLiteHelper db = new MySQLiteHelper(this);
String result = data.getStringExtra("result"); //Take the materia from Dialog
int color = data.getIntExtra("color", 1); //Take the color from Dialog
Materia materia;
materia = new Materia();
materia.setMateria(result); //put the name materia into class materia
materia.setColor(color); //put the color materia into class materia
//Here i need to recognize row and column
db.addMateria(new Materia(result, color, row, column));
// Now use mTextView here
//View view = findViewById(clickedTextViewId);
TextView clickedtextView = (TextView) findViewById(clickedTextViewId); //(TextView) view;
if(clickedTextViewId == clickedtextView.getId()) {
clickedtextView.setText(result);
clickedtextView.setBackgroundColor(color);
}
}
if (resultCode == RESULT_CANCELED) {
//Nessuna materia inserita
}
}
}//onActivityResult
Aucun commentaire:
Enregistrer un commentaire