在这段代码中,我有一个 if else 块。在 if else 中,我想使用 bundle 包含一个按钮,但我已经尝试过,但出现错误。我的代码在下面,有人知道为什么我会收到错误吗?
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));
// }
//});
}
}