Android ActionBar Example
The action bar is an important design element, usually at the top of each screen in an app, that provides a consistent familiar look between Android apps. It is used to provide better user interaction and experience by supporting easy navigation through tabs and drop-down lists. It also provides a space for the app or activity’s identity, thus enabling the user to know their location in the app, and easy access to the actions that can be performed.
1. Main Activity.java
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.add:
count = (TextView) findViewById(R.id.textView);
count.setText("One by One Add is clicked");
return (true);
case R.id.reset:
count = (TextView) findViewById(R.id.textView);
count.setText("Nothing is selected");
return (true);
case R.id.about:
Toast.makeText(this, R.string.about_toast, Toast.LENGTH_LONG).show();
return (true);
case R.id.exit:
finish();
return (true);
}
return (super.onOptionsItemSelected(item));
}
2. menu/main.xml
<item
android:id="@+id/action_speech"
android:icon="@drawable/microphone"
android:showAsAction="ifRoom"
android:title="@string/Speech"/>
<item
android:id="@+id/action_call"
android:icon="@drawable/call"
android:showAsAction="ifRoom"
android:title="@string/call"/>
<item
android:id="@+id/action_done"
android:icon="@drawable/done"
android:showAsAction="ifRoom"
android:title="@string/Done"/>
<item android:id="@+id/action_contacts"
android:showAsAction="never"
android:title="Contacts"/>
<item android:id="@+id/action_settings"
android:showAsAction="never"
android:title="Settings"/>
<item android:id="@+id/action_status"
android:showAsAction="never"
android:title="Status" />
Comments
Dnyanesh Kalal
Wed, 07/26/2017 - 16:29
Permalink
Library
<p>It showing me error on import com.tutorialsee.NumberProgressBar</p>