0

我尝试制作 alertdialog 以便单击时会显示另一个活动,但这不起作用。这是我的代码:

protected void onListItemClick(ListView l, View v, int position, long id) {

    final Entity_Brand brand = adapterBrand.getItem(position);

    CharSequence[] items = { "Cross Country(XC)", "All Mountain(AM)",
            "Free Ride(FR)", "DownHill(DH)", "DirtJump(DJ)", "Road Bike" };
    AlertDialog.Builder builder = new AlertDialog.Builder(
            Brand_ListView_Activity.this);
    builder.setIcon(R.drawable.icon_alert);
    builder.setTitle(brand.getNama_brand());
    builder.setItems(items, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int item) {
            switch (item) {
            case 0:
                Toast.makeText(Brand_ListView_Activity.this,
                        R.layout.test, Toast.LENGTH_LONG).show();
                break;
            }
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

我真的很需要帮助。太感谢了 :)

4

2 回答 2

1
Dialog d = new Dialog(this);
d.setContentView(R.layout.your_layout);
d.show();

在哪里引用你的活动

于 2012-06-26T08:16:23.583 回答
1

我猜你想创建一个自定义对话框

于 2012-06-26T08:05:09.647 回答