How to implement DrawerArrowToggle from Android appcompat v7 21 library

First, you should know now the android.support.v4.app.ActionBarDrawerToggle is deprecated. You must replace that with android.support.v7.app.ActionBarDrawerToggle. Here is my example and I use the new Toolbar to replace the ActionBar. MainActivity.java public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar); DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); … Read more

RecyclerView header and footer

in your adapter add this class: private class VIEW_TYPES { public static final int Header = 1; public static final int Normal = 2; public static final int Footer = 3; } then Override the following method like this: @Override public int getItemViewType(int position) { if(items.get(position).isHeader) return VIEW_TYPES.Header; else if(items.get(position).isFooter) return VIEW_TYPES.Footer; else return VIEW_TYPES.Normal; … Read more

Action bar navigation modes are deprecated in Android L

The new Android Design Support Library adds TabLayout, providing a tab implementation that matches the material design guidelines for tabs. A complete walkthrough of how to implement Tabs and ViewPager can be found in this video Now deprecated: The PagerTabStrip is part of the support library (and has been for some time) and serves as … Read more

How can incoming calls be answered programmatically in Android 5.0 (Lollipop)?

Update with Android 8.0 Oreo Even though the question was originally asked for Android L support, people still seem to be hitting this question and answer, so it is worth describing the improvements introduced in Android 8.0 Oreo. The backward compatible methods are still described below. What changed? Starting with Android 8.0 Oreo, the PHONE … Read more

Lollipop : draw behind statusBar with its color set to transparent

Method #1: To achieve a completely transparent status bar, you have to use statusBarColor, which is only available on API 21 and above. windowTranslucentStatus is available on API 19 and above, but it adds a tinted background for the status bar. However, setting windowTranslucentStatus does achieve one thing that changing statusBarColor to transparent does not: … Read more

Android 5.0 – Add header/footer to a RecyclerView

I had to add a footer to my RecyclerView and here I’m sharing my code snippet as I thought it might be useful. Please check the comments inside the code for better understanding of the overall flow. import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.util.ArrayList; public class RecyclerViewWithFooterAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { … Read more

DexIndexOverflowException issue after updating to latest appcompat and support library

This message sounds like your project is too large. You have too many methods. There can only be 65536 methods for dex. Since the gradle plugin 0.14.0 and the Build Tools 21.1.0 you can use the multidex support. Just add these lines in the build.gradle: android { defaultConfig { … // Enabling multidex support. multiDexEnabled … Read more