0
I’m trying to edit information that’s saved in the SQLITE gang. I’m working with fragments. But I’m making the following mistake:
FATAL EXCEPTION: main
Process: com.example.gerdaumanagement.gerdaumanagement, PID: 11997
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.gerdaumanagement.gerdaumanagement/com.example.gerdaumanagement.gerdaumanagement.adicionar_usuario}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)
at android.app.Activity.startActivityForResult(Activity.java:4225)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79)
at android.app.Activity.startActivityForResult(Activity.java:4183)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)
at android.app.Activity.startActivity(Activity.java:4522)
at android.app.Activity.startActivity(Activity.java:4490)
at com.example.gerdaumanagement.gerdaumanagement.usuario$UsuarioAdapter$2.onClick(usuario.java:218)
at android.view.View.performClick(View.java:5637)
at android.view.View$PerformClick.run(View.java:22429)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
I have a listview with all contacts, and in each contact I have an icon to edit and delete. The edit would be as follows:`
ImageView editarBt = (ImageView) view.findViewById(R.id.editar);
editarBt.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), adicionar_usuario.class);
intent.putExtra("nome", listaUser.get(auxPosition).getNome());
intent.putExtra("email", listaUser.get(auxPosition).getEmail());
intent.putExtra("np", listaUser.get(auxPosition).getNp());
intent.putExtra("tipoFunc", listaUser.get(auxPosition).getTipoFunc());
intent.putExtra("id", listaUser.get(auxPosition).getId());
getActivity().startActivity(intent);
}
});
When I click edit error happens.
I tried to change these codes:`
ImageView editarBt = (ImageView) view.findViewById(R.id.editar);
editarBt.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View view) {
Bundle data = new Bundle();
data.putString("nome", listaUser.get(auxPosition).getNome());
data.putString("email", listaUser.get(auxPosition).getEmail());
data.putString("np", listaUser.get(auxPosition).getNp());
data.putString("tipoFunc", listaUser.get(auxPosition).getTipoFunc());
data.putInt("id", listaUser.get(auxPosition).getId());
Fragment fragment = new adicionar_usuario();
fragment.setArguments(data);
}
});
`
Can anyone tell me the reason for this mistake?
You have a class called
adicionar_usuario
? It is not declared on Androidmanifest.xml– Leonardo Dias
She’s a Fragment, so she’s not in the manifest. @Leonardodias
– Lucas Charles
I believe this is the problem so, you can not do an Intent for a Fragment, you have to use the Fragmentmanager and change the Framelayout with the desired Fragment
– Leonardo Dias
@Leonardodias would you have an example of this? please?
– Lucas Charles
I put the example code in the answer Lucas
– Leonardo Dias