MapView in a Fragment (Honeycomb)

I’ve managed to resolve this by using TabHost in fragment. Here is the idea (briefly): MainFragmentActivity extends FragmentActivity (from support library) and has MapFragment. MyMapActivity extends MapActivity and contain MapView. LocalActivityManagerFragment hosts LocalActivityManager MapFragment extends LocalActivityManagerFragment. And LocalActivityManager contains MyMapActivity activity in it. Example implementation: https://github.com/inazaruk/map-fragment.

How to add a Dropdown item on the action bar

First option: menu/options.xml: <item android:icon=”@drawable/ic_menu_sort” android:showAsAction=”ifRoom”> <menu> <item android:id=”@+id/menuSortNewest” android:title=”Sort by newest” /> <item android:id=”@+id/menuSortRating” android:title=”Sort by rating” /> </menu> </item> Second option: menu/options.xml: <menu xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:id=”@+id/menuSort” android:showAsAction=”ifRoom” android:actionLayout=”@layout/action_sort” /> </menu> layout/action_sort.xml: <Spinner xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:background=”@drawable/ic_menu_refresh” android:entries=”@array/order” /> Docs for menu resources – http://developer.android.com/guide/topics/resources/menu-resource.html

Fragments onResume from back stack

For a lack of a better solution, I got this working for me: Assume I have 1 activity (MyActivity) and few fragments that replaces each other (only one is visible at a time). In MyActivity, add this listener: getSupportFragmentManager().addOnBackStackChangedListener(getListener()); (As you can see I’m using the compatibility package). getListener implementation: private OnBackStackChangedListener getListener() { OnBackStackChangedListener … Read more

SearchView’s OnCloseListener doesn’t work

I also meet this problem, and I have no choice but give up “oncloselistener”. Instead, you can get your menuItem, then setOnActionExpandListener. Then override unimplents methods. @Override public boolean onMenuItemActionExpand(MenuItem item) { // TODO Auto-generated method stub Log.d(“*******”,”onMenuItemActionExpand”); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { //do what you want to when close the … Read more

Changing overflow icon in the action bar

You can with a style, but you have to add it to the main Theme declaration. <resources> <!– Base application theme. –> <style name=”Your.Theme” parent=”@android:style/Theme.Holo”> <!– Pointer to Overflow style ***MUST*** go here or it will not work –> <item name=”android:actionOverflowButtonStyle”>@style/OverFlow</item> </style> <!– Styles –> <style name=”OverFlow” parent=”@android:style/Widget.Holo.ActionButton.Overflow”> <item name=”android:src”>@drawable/ic_action_overflow</item> </style> </resources> You also can … Read more

How to implement the Android ActionBar back button?

Selvin already posted the right answer. Here, the solution in pretty code: public class ServicesViewActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // etc… getActionBar().setDisplayHomeAsUpEnabled(true); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: NavUtils.navigateUpFromSameTask(this); return true; default: return super.onOptionsItemSelected(item); } } } The function NavUtils.navigateUpFromSameTask(this) requires you to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)