Send data to fragment from activity - Null object reference -


i trying send variable activity fragment several days withouth success. have read identic questions, didn't me.

main class:

public void onclick(view v) {       switch (v.getid()) {           case r.id.btn1:               local = "1";               break;         case r.id.btn2:             local = "2";             break;         case r.id.btn3:             local = "3";             break;     }      final bundle bundle = new bundle();     bundle.putstring("local", local);     final resultados_mapa mapa = new resultados_mapa();     mapa.setarguments(bundle);      fragment resultados = new resultados_mapa();     fragmenttransaction ft = getfragmentmanager().begintransaction();     ft.setcustomanimations(r.animator.slide_in_left, r.animator.slide_out_right);      ft.replace(r.id.barra_id, resultados);     ft.commit(); } 

fragment:

public view oncreateview(layoutinflater inflater, viewgroup container,                          bundle savedinstancestate) {     // inflate layout fragment         view layout_fragmento = inflater.inflate(r.layout.fragment_resultados__mapa, container, false);       arraylist<string> listitems=new arraylist<string>();      arrayadapter<string> adapter;      databaseoperations db =new databaseoperations(ctx);       try {          string local = getarguments().getstring("local");          toast.maketext(ctx, "local= "+local, toast.length_short).show();      } catch (exception e) {          log.e(tag_nome, "erro: "+e.getmessage());      } 

i can't problem!

the error is: attempt invoke virtual method 'java.lang.string android.os.basebundle.getstring(java.lang.string)' on null object reference


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -