Can you recycle an activity to use it in various activities in Android Studio?

1

I'm doing a project of an app that will have a button to make a new record, the app has as main activity the listing of data in listview by clicking on it the previous activity appears but to update. SqlLite

    
asked by jeanD 25.03.2018 в 03:15
source

1 answer

2

You can pass a parameter to your activity when invoking it to know if the operation is a creation or update.

Intent intent = new Intent(MyActivity.class);
Bundle b = new Bundle();
b.putInt("crear", Boolean.TRUE); //crear o actualizar
intent.putExtras(b);
startActivity(intent);
finish();

From your activity you pick up the parameter and you already know if you want to create or update.

    
answered by 25.03.2018 / 10:46
source