java - How to using Bundle in if else -
in code have if else block. in if else want include button using bundle have tried , error. code below, have ideas why getting error?
package com.apps.visitkuningan; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.view.window; import android.widget.button; import android.widget.imageview; import android.widget.textview; public class ketwisata extends activity{ intent iinntteen; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); this.requestwindowfeature(window.feature_no_title); setcontentview(r.layout.ket_wisata); string tampil = getintent().getextras().getstring("key"); imageview img1 = (imageview) findviewbyid(r.id.wisata); textview nama = (textview) findviewbyid(r.id.nama); textview alamat = (textview) findviewbyid(r.id.alamat); textview keterangan = (textview) findviewbyid(r.id.keterangan); button arahkan = (button) findviewbyid(r.id.arahkan); final bundle bundel2 = new bundle(); final string tampil2 = null; arahkan.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { bundel2.putstring("key", tampil2); iinntteen.putextras(bundel2); startactivity(iinntteen); } }); if(tampil.equalsignorecase("wis_balongdalem")) { img1.setbackgroundresource(r.drawable.wis_balong); nama.settext("balong dalem"); alamat.settext(r.string.add_balong); keterangan.settext(r.string.ket_balong); iinntteen = new intent(ketwisata.this, arahkan.class); tampil2 ="coba"; //tampil2 cant detected.. } if(tampil.equalsignorecase("wis_curugbangkong")) { img1.setbackgroundresource(r.drawable.wis_bangkong2); nama.settext("curug bangkong"); alamat.settext(r.string.add_bangkong); keterangan.settext(r.string.ket_bangkong); iinntteen = new intent(ketwisata.this, tentang.class); } if(tampil.equalsignorecase("wis_buperciberem")) { img1.setbackgroundresource(r.drawable.wis_ciberem2); nama.settext("buper cibeureum"); alamat.settext(r.string.add_ciberem); keterangan.settext(r.string.ket_ciberem); } if(tampil.equalsignorecase("wis_cibulan")) { img1.setbackgroundresource(r.drawable.wis_cibulan2); nama.settext("kolam cibulan"); alamat.settext(r.string.add_cibulan); keterangan.settext(r.string.ket_cibulan); } if(tampil.equalsignorecase("wis_balongcicerem")) { img1.setbackgroundresource(r.drawable.wis_balong); nama.settext("balong cicereum"); alamat.settext(r.string.add_cicerem); keterangan.settext(r.string.ket_cicerem); } if(tampil.equalsignorecase("wis_balongcigugur")) { img1.setbackgroundresource(r.drawable.wis_cigugur2); nama.settext("balong cigugur"); alamat.settext(r.string.add_cigugur); keterangan.settext(r.string.ket_cigugur); } if(tampil.equalsignorecase("wis_curugcilengkrang")) { img1.setbackgroundresource(r.drawable.wis_cilengkrang2); nama.settext("lembah cilengkrang"); alamat.settext(r.string.add_cilengkrang); keterangan.settext(r.string.ket_cilengkrang); } if(tampil.equalsignorecase("wis_cipari")) { img1.setbackgroundresource(r.drawable.wis_cipari2); nama.settext("taman purbakala cipari"); alamat.settext(r.string.add_cipari); keterangan.settext(r.string.ket_cipari); } if(tampil.equalsignorecase("wis_balongdarmaloka")) { img1.setbackgroundresource(r.drawable.wis_darmaloka2); nama.settext("balong darmaloka"); alamat.settext(r.string.add_darmaloka); keterangan.settext(r.string.ket_darmaloka); } if(tampil.equalsignorecase("wis_linggarjatiindah")) { img1.setbackgroundresource(r.drawable.wis_linggarjat2i); nama.settext("linggarjati indah"); alamat.settext(r.string.add_linggarjati); keterangan.settext(r.string.ket_linggarjati); } if(tampil.equalsignorecase("wis_guamaria")) { img1.setbackgroundresource(r.drawable.wis_guamaria); nama.settext("gua maria"); alamat.settext(r.string.add_guamaria); keterangan.settext(r.string.ket_guamaria); } if(tampil.equalsignorecase("wis_gedungnaskah")) { img1.setbackgroundresource(r.drawable.wis_muslinggar2); nama.settext("musium linggarjati"); alamat.settext(r.string.add_naskah); keterangan.settext(r.string.ket_naskah); } if(tampil.equalsignorecase("wis_buperpalutungan")) { img1.setbackgroundresource(r.drawable.wis_palutungan2); nama.settext("buper plautungan"); alamat.settext(r.string.add_palutungan); keterangan.settext(r.string.ket_palutungan); } if(tampil.equalsignorecase("wis_buperpaniis")) { img1.setbackgroundresource(r.drawable.wis_paniis2); nama.settext("buper paniis"); alamat.settext(r.string.add_paniis); keterangan.settext(r.string.ket_paniis); } if(tampil.equalsignorecase("wis_paseban")) { img1.setbackgroundresource(r.drawable.wis_paseban); nama.settext("gedung merapat lima"); alamat.settext(r.string.add_paseban); keterangan.settext(r.string.ket_paseban); } if(tampil.equalsignorecase("wis_gedungsahrir")) { img1.setbackgroundresource(r.drawable.wis_gedungsut); nama.settext("gedung sutan syahrir"); alamat.settext(r.string.add_syahrir); keterangan.settext(r.string.ket_syahrir); } if(tampil.equalsignorecase("wis_sanggariang")) { img1.setbackgroundresource(r.drawable.wis_sanggariang2); nama.settext("kolam renang sanggariang"); alamat.settext(r.string.add_sanggariang); keterangan.settext(r.string.ket_sanggariang); } if(tampil.equalsignorecase("wis_sangkanurip")) { img1.setbackgroundresource(r.drawable.wis_sangkanurip2); nama.settext("pemandian sangkanurip"); alamat.settext(r.string.add_sangkanurip); keterangan.settext(r.string.ket_sangkanhurip); } if(tampil.equalsignorecase("wis_curugsidomba")) { img1.setbackgroundresource(r.drawable.wis_sidomba2); nama.settext("sidomba"); alamat.settext(r.string.add_sidomba); keterangan.settext(r.string.ket_sidomba); } if(tampil.equalsignorecase("wis_talagaremis")) { img1.setbackgroundresource(r.drawable.wis_talagaremis); nama.settext("talagaremis"); alamat.settext(r.string.add_talagaremis); keterangan.settext(r.string.ket_talagaremis); } if(tampil.equalsignorecase("wis_tngc")) { img1.setbackgroundresource(r.drawable.wis_tngc); } if(tampil.equalsignorecase("wis_wadukdarma")) { img1.setbackgroundresource(r.drawable.wis_waduk2); nama.settext("waduk darma"); alamat.settext(r.string.add_waduk); keterangan.settext(r.string.ket_waduk); } if(tampil.equalsignorecase("wis_abn")) { img1.setbackgroundresource(r.drawable.wis_abn); } if(tampil.equalsignorecase("wis_hasanmaulana")) { img1.setbackgroundresource(r.drawable.wis_hasanmaulana); nama.settext("gedung hasan maulani"); alamat.settext(r.string.add_hasanmaulana); keterangan.settext(r.string.ket_hasanmaulana); } if(tampil.equalsignorecase("wis_makamvanbeck")) { img1.setbackgroundresource(r.drawable.wis_makamvanbeck); nama.settext("makam van beck"); alamat.settext(r.string.add_makamvanbeck); keterangan.settext(r.string.ket_makamvanbeck); } if(tampil.equalsignorecase("wis_situscangkuang")) { img1.setbackgroundresource(r.drawable.wis_situscangkuang); nama.settext("situs cangkuang"); alamat.settext(r.string.add_cangkuang); keterangan.settext(r.string.ket_cangkuang); } if(tampil.equalsignorecase("wis_talaganilem")) { img1.setbackgroundresource(r.drawable.wis_talaganilem); nama.settext("talaganilem"); alamat.settext(r.string.add_talaganilem); keterangan.settext(r.string.ket_talaganilem); } //arahkan.setonclicklistener(new onclicklistener() { // @override // public void onclick(view arg0) { // startactivity(new intent(ketwisata.this, arahkan.class)); // } //}); } }
before doing line: getintent().getextras().anything_else
make sure that: getintent() != null && getintent().getextras() != null
can check getintent().getextras().isempty()
Comments
Post a Comment