我正在尝试让菜单按钮显示此消息"您确定要退出应用程序吗?"有两个按钮是和否。
我制作了这段代码,但是收到了以下错误消息:无法访问的代码
这是我的代码:
public boolean onOptionsItemSelected(MenuItem paramMenuItem)
{
switch (paramMenuItem.getItemId())
{
default:
return super.onOptionsItemSelected(paramMenuItem);
}
new AlertDialog.Builder(this).setMessage("re you sure you want to exite the app?").setPositiveButton("yes", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
{
System.exit(0);
}
}).setNegativeButton("no", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {}
}).show();
return true;
}
答案 0 :(得分:1)
您的switch语句不正确。
print_r( $client->products->create( array(
'title' => 'Nile - Over Counter Basin',
'sku' => '91081_Nile',
'type' => 'simple',
'regular_price' => '7260',
'sale_price' => '5445',
'description' => 'Nile - Over Counter BasinOver Counter BasinHindware Italian CollectionContemporary design with smooth flowing line Space for toiletries',
'dimensions'=>array( 'length' =>'67.5' ,'width' =>'39.5','height'=>'12.5'),
'categories'=>array( ' SANITARYWARE' =>'592',' WASHBASIN' =>'650',' Table Top Wash Basin' =>'508'),
'images' =>Array ('91081_Nile'=>Array('src'=>'http://www.somethingsomething.com/images/products/91081/2.jpg','title'=>'91081_Nile','position'=>'0') ),
'short_description'=>'Contemporary design with smooth flowing line Space for toiletries <table id="ProductDescriptiontable"><tr><td>Brand</td><td>:</td><td class="thirdcolumn">Hindware</td></tr><tr><td>Product Name</td><td>:</td><td class="thirdcolumn">Nile - Over Counter Basin</td></tr><tr><td>Product Description</td><td>:</td><td class="thirdcolumn">Table Top Wash Basin</td></tr></tr><tr><td>Product Color</td><td>:</td><td class="thirdcolumn">StarwhiteIvory</td></tr></table>',
'enable_html_short_description' => true, // This is the line you need to add
) ) ) ;
所以,像这样:
switch (item.getItemId()) {
case R.id.action_add:
//your code
return true;
case R.id.action_settings:
//your code
return true;
default:
return false;
}
和菜单
public boolean onOptionsItemSelected(MenuItem paramMenuItem) {
switch (paramMenuItem.getItemId()) {
case R.id.action_exit:
showExitDialog();
return true;
default:
return super.onOptionsItemSelected(paramMenuItem);
}
}
private void showExitDialog() {
new AlertDialog.Builder(this).setMessage("Are you sure you want to exite the app?")
.setPositiveButton("yes", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
System.exit(0);
}
})
.setNegativeButton("no", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
}
})
.show();
}