Buggy code:
public class RunningProcessesView extends FrameLayout implements RecyclerListener , AdapterView . OnItemClickListener , RunningState . OnRefreshUiListener { final int mMyUserId ; long SECONDARY_SERVER_MEM ; final HashMap < View , RunningProcessesView . ActiveItem > mActiveItems = new HashMap < View , RunningProcessesView . ActiveItem > ( ) ; ActivityManager mAm ; RunningState mState ; Fragment mOwner ; Runnable mDataAvail ; StringBuilder mBuilder = new StringBuilder ( 128 ) ; BaseItem mCurSelected ; ListView mListView ; View mHeader ; RunningProcessesView . ServiceListAdapter mAdapter ; LinearColorBar mColorBar ; TextView mBackgroundProcessText ; TextView mAppsProcessText ; TextView mForegroundProcessText ; int mLastNumBackgroundProcesses = - 1 ; int mLastNumForegroundProcesses = - 1 ; int mLastNumServiceProcesses = - 1 ; long mLastBackgroundProcessMemory = - 1 ; long mLastForegroundProcessMemory = - 1 ; long mLastServiceProcessMemory = - 1 ; long mLastAvailMemory = - 1 ; Dialog mCurDialog ; MemInfoReader mMemInfoReader = new MemInfoReader ( ) ; public static class ActiveItem { View mRootView ; BaseItem mItem ; RunningServiceInfo mService ; RunningProcessesView . ViewHolder mHolder ; long mFirstRunTime ; boolean mSetBackground ; void updateTime ( Context context , StringBuilder builder ) { } } public static class ViewHolder { public View rootView ; public ImageView icon ; public TextView name ; public TextView description ; public TextView size ; public TextView uptime ; public ViewHolder ( View v ) { } public RunningProcessesView . ActiveItem bind ( RunningState state , RunningState . BaseItem item , StringBuilder builder ) { } } static class TimeTicker extends TextView { public TimeTicker ( Context context , AttributeSet attrs ) { } } class ServiceListAdapter extends BaseAdapter { final RunningState mState ; final LayoutInflater mInflater ; boolean mShowBackground ; ArrayList < RunningState . MergedItem > mOrigItems ; final ArrayList < RunningState . MergedItem > mItems = new ArrayList < RunningState . MergedItem > ( ) ; ServiceListAdapter ( RunningState state ) { } void setShowBackground ( boolean showBackground ) { } boolean getShowBackground ( ) { } void refreshItems ( ) { } public boolean hasStableIds ( ) { } public int getCount ( ) { } @ Override public boolean isEmpty ( ) { } public Object getItem ( int position ) { } public long getItemId ( int position ) { } public boolean areAllItemsEnabled ( ) { } public boolean isEnabled ( int position ) { } public View getView ( int position , View convertView , ViewGroup parent ) { } public View newView ( ViewGroup parent ) { } public void bindView ( View view , int position ) { } } void refreshUi ( boolean dataChanged ) { } public void onItemClick ( AdapterView < ? > parent , View v , int position , long id ) { } private void startServiceDetailsActivity ( RunningState . MergedItem mi ) { } public void onMovedToScrapHeap ( View view ) { } public RunningProcessesView ( Context context , AttributeSet attrs ) { } public void doCreate ( Bundle savedInstanceState ) { mAm = ( ( ActivityManager ) ( getContext ( ) . getSystemService ( ACTIVITY_SERVICE ) ) ) ; mState = RunningState . getInstance ( getContext ( ) ) ; LayoutInflater inflater = ( ( LayoutInflater ) ( getContext ( ) . getSystemService ( LAYOUT_INFLATER_SERVICE ) ) ) ; inflater . inflate ( running_processes_view , this ) ; mListView = ( ( ListView ) ( findViewById ( list ) ) ) ; View emptyView = findViewById ( empty ) ; if ( emptyView != null ) { mListView . setEmptyView ( emptyView ) ; } mListView . setOnItemClickListener ( this ) ; mListView . setRecyclerListener ( this ) ; mAdapter = new RunningProcessesView . ServiceListAdapter ( mState ) ; mListView . setAdapter ( mAdapter ) ; mHeader = inflater . inflate ( running_processes_header , null ) ; <START_BUG> mListView . addHeaderView ( mHeader ) ; <END_BUG> mColorBar = ( ( LinearColorBar ) ( mHeader . findViewById ( color_bar ) ) ) ; Resources res = getResources ( ) ; mColorBar . setColors ( res . getColor ( running_processes_system_ram ) , res . getColor ( running_processes_apps_ram ) , res . getColor ( running_processes_free_ram ) ) ; mBackgroundProcessText = ( ( TextView ) ( mHeader . findViewById ( freeSize ) ) ) ; mAppsProcessText = ( ( TextView ) ( mHeader . findViewById ( appsSize ) ) ) ; mForegroundProcessText = ( ( TextView ) ( mHeader . findViewById ( systemSize ) ) ) ; ActivityManager . MemoryInfo memInfo = new ActivityManager . MemoryInfo ( ) ; mAm . getMemoryInfo ( memInfo ) ; SECONDARY_SERVER_MEM = memInfo . secondaryServerThreshold ; } public void doPause ( ) { } public boolean doResume ( Fragment owner , Runnable dataAvail ) { } void updateTimes ( ) { } @ Override public void onRefreshUi ( int what ) { } }

Fix:
mListView . addHeaderView ( mHeader , null , false ) ;