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
-
Titanium Backup Pro 5.5.0 - proper crackTitanium Backup is the most powerful backup tool on Android, and then some. You can backup, restore…
-
At the moment SPB Shell is the best 3D Launcher out in the market. They are working really hard to …
-
The King Of Fighters v12.07.0120 legendary fighters battle for glory! The formidable roster of “THE KING OF FIGHTERS Android” fea…
-
Juggernaut Revenge of SoveringAn entirely new breed of RPG has risen from the smoldering ashes of Haradan. You, as one of 5 legen…
-
How To Take Screenshot On Android Phones'>There are several applications in the Android Market, which allow a screenshot. Applications such …
-
xScope Browser Pro - Web File v7.22 (Paid Version) Android Apk App DownloadxScope Browser Pro - Web File v7.22 Requirements: Android version 4.0 and higher, supports App2SD…
-
aTilt 3D Labyrinth v1.5.2 Apk FreeaTilt 3D Labyrinth v1.5.2 Requirements: Android O/S : 1.5+ Android Apk Free aTilt 3D Labyrint…

Post a Comment
Post a Comment