Create an Android Project
Create an android projection alongside next data to implement bill of fare inwards your app in addition to to grip bill of fare exceptional click.
Application name: Menu Item Clickable
Company Domain: viralandroid.com
Package name: com.viralandroid.menuitemclickable
Minimum SDK: Android 2.2 (API 8 Froyo)
Add Menu Items
First, y’all accept to add together bill of fare exceptional to your menu_main.xml file, which seems similar this.
Handling Menu Item Click Events
Now, what I’m going to exercise is, when y’all click bill of fare icon, the novel action opens in addition to when y’all click search in addition to setting y’all volition able run into a toast message.
Modified code of MainActivity.java file seems similar this.
Above Intent intent = novel Intent(this,SecondActivity.class); allows y’all to opened upwardly novel activity. When y’all click novel action push in addition to Toast.makeText(this, “Android Menu is Clicked”, Toast.LENGTH_LONG).show();, displays a piffling message when y’all click bill of fare items such every bit setting in addition to search.
Create Second Activity
Your 2d action coffee in addition to XML file code seems similar this.
And your AndroidManifest.xml file seems similar this.
Finally, y’all accept done all. Now, run your application which seems similar this. If y’all accept problem, delight shipping service your work inwards the comment box.
Download Complete Example Project
Download complete menu exceptional click project rootage code from GitHub.