I created a layout that opens a dialog box, and after entering the dialog box, the user selects ok / cancel. I want to update listView to request data
Here is my layout that will open the dialog:
button.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent myIntent = new Intent(SchoolActivity.this, InsertSchool.class);
update();
startActivity(myIntent);
updateList();
}
});
update();
cursor.requery();
String[] from = new String[]{Database.KEY_ID2, Database.KSCHOOL, Database.KSCHOOLCODE};
int[] to = new int[]{R.id.rid, R.id.rt1, R.id.rt2};
cursorAdapter =
new SimpleCursorAdapter(this, R.layout.row_school, cursor, from, to);
listContent.setAdapter(cursorAdapter);
After clicking this button, I want to update the listView. Here is the dialogue (I think the update will be done here on the ok and cancel buttons).
ib.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent=new Intent(InsertSchool.this, SchoolActivity.class);
startActivity(intent);
}
});
update();
mySQLiteAdapter = new Database(this);
mySQLiteAdapter.openToWrite();
cursor = mySQLiteAdapter.queueSchoolAll();
ib1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String data1 = ie1.getText().toString();
String data2 = ie2.getText().toString();
mySQLiteAdapter.insertSchool(data1, data2);
updateList();
Toast.makeText(getApplicationContext(), "Saved",
Toast.LENGTH_SHORT).show();
Intent myIntent = new Intent(InsertSchool.this, SchoolActivity.class);
update();
startActivity(myIntent);
mySQLiteAdapter.close();
}
}
});
source
share