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
-
[Gameloft] Wonder Zoo S40, S60v3, S60v5, Symbian^3, BellaGameloft has just released this new great game " Wonder Zoo " in 2012, a zoo management g…
-
Andy (Siri for Android) v4.3 APKAndy is a voice controlled access to encyclopedic information on a vast array of topics. Ask anyt…
-
Muffin Knight v1.7 (Paid Version) Android Apk Game DownloadFootball Manager Handheld 2012 v3.5 Requirements: Android v2.2+ Overview: The World’s best-sell…
-
Jelly bean keyboard PROAndroid Jelly Bean Keyboard from Android 4.1 ported to work on your device! Jelly Bean Keyboa…
-
Viral Money MachineViral Money Machine $6,140 in 9 Days? How AJ Created …
-
Apple iPhone 5 FeaturesIf we believe the rumours, Apple's next generation phone, iPhone 5 will be launched in October…
-
TNA Wrestling iMPACT v1.0.2 (Paid Version) Android Apk Game DownloadTNA Wrestling iMPACT v1.0.2 Requirements: 2.0.1 Strike, stomp, grapple and throw your way to t…
Post a Comment
Post a Comment