Reputation: 329
I have a button in my screen and i want to open up the menuInflator when the button is pressed i tried the following code but it does not work
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
switch (arg0.getId()) {
case R.id.btnmenu1:
// TODO Auto-generated method stub
MenuInflater inflatemenu = getMenuInflater();
inflatemenu.inflate(R.menu.bmenu, menu);
break;
}
How do i make it work???
Upvotes: 1
Views: 119
Reputation: 21561
Call
openOptionsMenu();
method when click on button
or else set android:onClick="myOnClickMethod"
on your Button
in xml and then have:
public myOnClickMethod(View v) {
openOptionsMenu();
}
in your activity.
Upvotes: 2