I have searched and searched Google, Stack Overflow, etc. for an answer to this and failed!
I wish to programatically disable/enable selected radio buttons in a single Android preference.
For example, there is a radio button preference with 6 choices, but depending on some condtions (not related to the preferences) some of them will be unselectable and should be shown as disabled.
I can see how we can disable complete radio button groups, but not individual radio buttons
Can Anyone help?
AFAIK, this is not supported by the built-in ListPreference. You are welcome to write your own custom Preference, or perhaps extend ListPreference, where you supply your own Adapter and disable certain items that way.
Related
Attached screenshot of netflix app with left side menu I am able to develop a side menu with customized icon and header in it. I want, when the focus comes on header fragment it should expand on top of row fragment, that is not collapsing the row fragment, the same as Netflix and hotstar are doing. How can I achieve it?
unfortunately, the HeaderSupportFragment used in the BrowseSupportFragment is not configurable enough to achieve this kind of design. Leanback is great to build quickly and easily media browser app but when it comes to "complex" design, it's easier to use custom component.
The major difference also here, is that the left menu of the BrowseSupportFragment show each rows header name displayed in the screen (that's why it's called HeaderSupportFragment). Here you want to show different entries like search, home, settings, etc.
To make this kind of view, I would suggest creating your own custom view and use a basic Fragment. I followed this tutorial which can be useful to handle menu open/close animation (I mixed it with a ConstraintLayout to simplify the animation and I made the menu overlap the rest of the screen instead of moving everything.)
See the tutorial: https://medium.com/building-for-android-tv/building-for-android-tv-episode-3-381e041dfec7
I'm currently learning Android development from a book and I've come to the topic of radio buttons. The book explains that you handle radio button clicks (within a RadioGroup) using setOnCheckedChangeListener() with an anonymous OnCheckedChangeListener class as an argument.
However, according to the Android documentation you can set the onClick attribute on radio buttons to simply refer to a method of your design and handle clicks there.
Is there a reason to choose one over the other? What I'm asking is if there is some difference between the two that I'm missing, or if they simply both do the same thing.
setOnCheckedChangeListener() is listening to checked state, so if it is changed programmatically your code will be triggered. onClick listener only detects changes on checked state only if the element is clicked.
I see this layout item in a lot of apps but I don't know the name. What is the name of this layout item pictured in the images below?
Image 1
Image 2
You might want to take a look at the PopupMenu class.
Also, this is used for the overflow menu in the Action Bar, you can read more about it here.
They are menus, read official docs.
Contextual Menus are used when you need to show a list of choices, example when you long press in a item in ListView.
Hi Guys
I want to use ICS spinner in my android application so i can move between views (min API 10), I'm using ABS.
So how can i add and use spinner( but please A detailed explanation ) in my case, and how to add additional button in the ABS?
Thax for your time :)
ICS Spinner : like the gamil application to choose between your account
Use setNavigationMode() and NAVIGATION_MODE_LIST with ActionBar, as is illustrated in this sample application and as is covered in the documentation.
additional button like the share button in ICS action bar but to do another job like creating something add somthing
You do this the same way that you add items to the overflow menu (or the old options menu), except that you include android:showAsAction in your menu XML (e.g., android:showAsAction="always"), as is illustrated in this sample application and as is covered in the documentation.
I'm setting up an action bar with Sherlock with 3 items/icons.
Running on a ICS emulator, I only can see 2 icons. And moreover: NO overflow menu (those 3 dots-icon)!
I only get the 3rd icon if I press the menu button of the phone.
Do I have to force the overflow icon, and if so how can I do so?
Do I have to force the overflow icon, and if so how can I do so?
All you need to do is have your theme inherit from one of the .ForceOverflow themes. Note this will only work for Android 2.0 and 3.0. In 4.0 the native ActionBar component is used instead, and the overflow item is only displayed if the device does not have a menu key.
Do I have to force the overflow icon
No.
Your emulator is set up, by default, to emulate a device that has an off-screen MENU key, like the Nexus S. Such devices will not have an on-screen overflow menu button -- users will use the MENU key to access the overflow. Many of those devices, like the Nexus S, will be ones upgraded from Android 2.x, where the user will already be used to pressing the MENU key to get what used to be the options menu and now is the overflow menu.
You can switch your emulator to emulate a device without an off-screen MENU key. In your AVD Manager, for an AVD, add the "Hardware Back/Home keys" property (which, despite the name, also has the MENU key) and set it to be true or false as you wish.