Home
› Uncategorized
Example of Action Menu with grouped CheckBox.
Create /res/menu/activity_main.xml to define action menu.
The checked status will not be updated automatically. We can change it in onOptionsItemSelected() callback method.
Create /res/menu/activity_main.xml to define action menu.
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/menu_settings" android:title="@string/menu_settings" android:orderInCategory="100" android:showAsAction="never" /> <group android:checkableBehavior="single"> <item android:id="@+id/selecta" android:title="Selection A" android:checked="true"/> <item android:id="@+id/selectb" android:title="Selection B" /> <item android:id="@+id/selectc" android:title="Selection C" /> </group> </menu>
The checked status will not be updated automatically. We can change it in onOptionsItemSelected() callback method.
package com.example.androidactionbar; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.MenuItem; import android.widget.Toast; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.selecta: item.setChecked(true); Toast.makeText(getApplicationContext(), "A Selected", Toast.LENGTH_LONG).show(); return true; case R.id.selectb: item.setChecked(true); Toast.makeText(getApplicationContext(), "B Selected", Toast.LENGTH_LONG).show(); return true; case R.id.selectc: item.setChecked(true); Toast.makeText(getApplicationContext(), "C Selected", Toast.LENGTH_LONG).show(); return true; default: return super.onOptionsItemSelected(item); } } }
-- Delivered by Feed43 service
Related Posts
There is no other posts in this category.Popular
-
The Avengers – Iron Man Mark VII 1.1 APKThe Avengers – Iron Man Mark VII 1.1 APK Suit up and Blast off in the First-Ever Fully-Interactive …
-
How To: Copy And Paste In Android Mobile'>The copy, cut, paste and select the features Android has many nuances. In this how-to, we will foc…
-
[Android] Battleloot Adventure HD v1.0.7 (apk + data)In Battleloot Adventure HD , let's roll out and your adventure is about to begin. In the kingdo…
-
[Android] The Dark Knight Rises v1.1.1 APK by GameloftThe Dark Knight Rises is one of the hottest games just released by Gameloft in July 2012 on Androi…
-
[Android] Zuma's Revenge HD v1.0.8 Free Download [Mediafire]Zuma’s Revenge Android , similar to Bonsai Blast, is one of the most fascinating puzzle game fr…
-
LG GW620, ANDROID PhoneLG GW620 , is the first Android smartphone from LG with a full touch screen display. This sophisti…
-
Angry Birds Space v1.0.1 for AndroidAngry Birds Space v1.0.1 for Android The #1 mobile game of all time blasts off into space! All new …
Post a Comment
Post a Comment