android-3.0-honeycomb

How to use Holo.Light theme, and fall back to 'Light' on pre-honeycomb devices?

不想你离开。 提交于 2019-11-26 06:55:41
问题 I\'d like to use the Holo.Light theme on devices that support it, and fall back to the regular Light theme on other devices. At the moment, referencing Holo.Light works fine on 3.0+, but older APIs simply revert to the default \'dark\' theme. Can I achieve what I want with with style inheritance? 回答1: You have to create a custom theme and save it in some directories to finally set this theme as the default one for the app First, in values add a themes.xml like this: <?xml version="1.0"

SearchView&#39;s OnCloseListener doesn&#39;t work

牧云@^-^@ 提交于 2019-11-26 06:29:38
问题 I\'m trying to add support for the SearchView in the Android 3.0+ ActionBar, but I can\'t get the OnCloseListener to work. Here\'s my code: @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu, menu); searchView = (SearchView) menu.findItem(R.id.search_textbox).getActionView(); searchView.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { searchLibrary(newText); return false; } @Override

Fragments onResume from back stack

旧巷老猫 提交于 2019-11-26 04:08:45
问题 I\'m using the compatibility package to use Fragments with Android 2.2. When using fragments, and adding transitions between them to the backstack, I\'d like to achieve the same behavior of onResume of an activity, i.e., whenever a fragment is brought to \"foreground\" (visible to the user) after poping out of the backstack, I\'d like some kind of callback to be activated within the fragment (to perform certain changes on a shared UI resource, for instance). I saw that there is no built in

Was PreferenceFragment intentionally excluded from the compatibility package?

放肆的年华 提交于 2019-11-26 03:47:10
问题 I\'m looking to write preferences that can be applied to both 3.0 and pre-3.0 devices. Discovering that PreferenceActivity contains deprecated methods (although these are used in the accompanying sample code), I looked at PreferenceFragement and the compatibility package to solve my woes. It appears, though, that PreferenceFragment isn\'t in the compatibility package. Can anyone tell me whether this was intentional? If so, can I easily target a range of devices (i.e. < 3.0 and >=3.0) or will

How to add a Dropdown item on the action bar

旧城冷巷雨未停 提交于 2019-11-26 03:34:58
问题 In my Android Honeycomb application I use Tabs as the navigation style. I would like to add one item next to the overflow button, but I want that item to be a dropdown list, and the user will be able to select an option there, but not related to navigation. What is the easiest way since I\'m using mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); Is it possible to do it without using a custom view? 回答1: First option: menu/options.xml: <item android:icon="@drawable/ic_menu_sort"

getActionBar() returns null

拜拜、爱过 提交于 2019-11-26 01:26:55
问题 I\'m having an odd problem. I am making an app with targetsdk 13. In my main activity\'s onCreate method i call getActionBar() to setup my actionbar. This works fine when running on the Android 3.2 emulator, but when using Android 3.0 and 3.1 the getActionBar() method returns null. I find this extremely odd, and i cannot see any reason why it would do so. Is this a bug with the emulators or is there something i need to do, in order to ensure that my application has an actionbar? SOLUTION: I

MapView in a Fragment (Honeycomb)

假如想象 提交于 2019-11-26 01:06:04
问题 now that the final SDK is out with google apis - what is the best way to create a Fragment with a MapView? MapView needs a MapActivity to work right. Having the Activity managing the Fragments inherit from MapActivity (bad solution because it goes against the idea that Fragments are self contained) and use a regular xml based layout does not work. I get a NullPointerException in MapActivity.setupMapView(): E/AndroidRuntime( 597): Caused by: java.lang.NullPointerException E/AndroidRuntime( 597

How to hide action bar before activity is created, and then show it again?

最后都变了- 提交于 2019-11-26 01:04:11
问题 I need to implement splash screen in my honeycomb app. I use this code in activity\'s onCreate to show splash: setContentView(R.layout.splash); getActionBar().hide(); and this code to show main UI after sometime: setContentView(R.layout.main); getActionBar().show(); But before onCreate is called and splash appears, there is small amount of time when action bar shown. How can I make action bar invisible? I tried to apply theme to activity without action bar: <item name=\"android

Why fragments, and when to use fragments instead of activities?

牧云@^-^@ 提交于 2019-11-26 00:34:48
问题 In Android API 11+, Google has released a new class called Fragment . In the videos, Google suggests that whenever possible (link1, link2), we should use fragments instead of activities, but they didn\'t explain exactly why. What\'s the purpose of fragments and some possible uses of them (other than some UI examples that can be easily be achieved by simple views/layouts)? My question is about fragments: What are the purposes of using a fragment? What are the advantages and disadvantages of

How do I add a Fragment to an Activity with a programmatically created content view

一曲冷凌霜 提交于 2019-11-26 00:30:02
问题 I want to add a Fragment to an Activity that implements its layout programmatically. I looked over the Fragment documentation but there aren\'t many examples describing what I need. Here is the type of code I tried to write: public class DebugExampleTwo extends Activity { private ExampleTwoFragment mFragment; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FrameLayout frame = new FrameLayout(this); if (savedInstanceState == null) { mFragment