In the app Add, delete function has, this time we do change function. Modify the store name in the corresponding entry when you click the items item in the project. Click items to jump out of a dialog box containing the input box, modify button, and Cancel button:
Alertdialog.builder builder = new Builder (mainactivity.this); Builder.settitle ("delete?"); Final EditText et = new EditText (mainactivity.this);
Builder.setview (ET); Builder.setpositivebutton ("Modify", new Dialoginterface.onclicklistener () {@Override public void OnClick (DIALOGINTERFAC e dialog, int which) {modify logic}}); Builder.setnegativebutton ("Cancel", new Dialoginterface.onclicklistener () {@Override public void OnClick (DIALOGINTERFAC e dialog, int which) {//dialog box delete Dialog.dismiss (); } });
Add the Modified code:
String name = Et.gettext (). toString (); if (name! = NULL &&! "). EndsWith (name)) { //modify Local Data Upda (name,shoplist.get (position)); Modify the corresponding data inside the shoplist shoplist.get (position). SetName (name); Refresh shopadapter.notifydatasetchanged ();}
Implement Updatelocaldata ():
private void Updatelocaldata (String name,shop shop) {contentvalues values = new Contentvalues (); Values.put ("Shopname", name); Db.update ("Shopinfo", values, "Shopname =?", New String[]{shop.getname ()});
Eatwhatapp Development Combat (eight)