menu items doesn't work on click
<p>I want to add menu in my application,but it does not working. Menu's items display correctly but when i select one of them, then nothing happened.
Also i want to show an alert dialog on item2.
plz help me. I am new to android.</p>

<p>thanks in advance</p>

<p>i have tried this</p>

<pre><code>public boolean onCreateOptionsMenu(Menu menu) {
    // TODO Auto-generated method stub
    MenuInflater in=getMenuInflater();
    in.inflate(R.menu.activity_main, menu);
    return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    Toast.makeText(getApplicationContext(), "ok", Toast.LENGTH_SHORT).show();
    switch (item.getItemId()) {
        case R.id.item1:
            this.finish();
            break;
        case R.id.item2:
            AlertDialog.Builder bb=new AlertDialog.Builder(this);
            bb.setMessage("Are you sure to exit?").setCancelable(false);
            bb.setPositiveButton("yes", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                }   
            });
            bb.setNegativeButton("No", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                }
            }); 
            AlertDialog alrt=bb.create();
            //alrt.setTitle("Are you sure to exit?");
            alrt.show();
            break;
    }
    return super.onOptionsItemSelected(item);
}
</code></pre>
