我尝试制作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();
}
我真的需要帮助。非常感谢你:))
答案 0 :(得分:1)
我想你要创建一个custom dialog
答案 1 :(得分:1)
Dialog d = new Dialog(this);
d.setContentView(R.layout.your_layout);
d.show();
如果你的活动引用了这个