Plugins architecture for an Android app? [closed]

I have done a framework that works like Robo-guice with some of its primary IoC functions. (Cut down on boilerplate codes that load views/service etc…) But the core of which, I believe is the solution to your problem, is the ability to load separate APK “plugin” files, that includes “res” as well as <layouts>.xml files. … Read more

What should I pass for root when inflating a layout to use for a MenuItem’s ActionView?

I would simply do it like this: menuItem.setActionView(R.layout.action_view_layout); Let Android inflate the view for you. If you need to do some extra changes on this ImageView call ImageView imageView = (ImageView) menuItem.getActionView(); Update In order to cater to your curiosity. That is what folks from Google do under the hood: public MenuItem setActionView(int resId) { … Read more

Problem inflating custom view for AlertDialog in DialogFragment

The first error line gives me the hint that this is related to how you are creating your dialog – not the dialog itself. Are you creating the dialog automatically (which could mean this gets called before the views are all set up) or in response to a button click? I initially had problems with … Read more

Unconditional layout, inflation from view adapter: Should use View Holder pattern

Try this static class ViewHolder { private TextView friendsname; private ImageView thumb_image; private CheckBox cb; } public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder mViewHolder = null; HashMap<String, String> song = null; if (convertView == null) { song = new HashMap <String, String>(); mViewHolder = new ViewHolder(); LayoutInflater vi = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); … Read more

NPE while inflating layout (Attempt to invoke virtual method ‘boolean java.lang.String.equals(java.lang.Object)’ on a null object reference)

Change <view to <View, because view is not about empty view. It’s for custom view defined through class attr, like below: <view android:layout_width=”wrap_content” android:layout_height=”wrap_content” class=”com.your.package.YourCustomView” /> And you got Caused by: java.lang.NullPointerException: Attempt to invoke virtual method ‘boolean java.lang.String.equals(java.lang.Object)’ on a null object reference because of LayoutInflater tries to parse class attr: LayoutInflater source code … Read more

How does the getView() method work when creating your own custom adapter?

1: The LayoutInflater takes your layout XML-files and creates different View-objects from its contents. 2: The adapters are built to reuse Views, when a View is scrolled so that is no longer visible, it can be used for one of the new Views appearing. This reused View is the convertView. If this is null it … Read more

How to change the background color of the options menu?

After spending a considerable amount of time trying all the options, the only way I was able to get an app using AppCompat v7 to change the overflow menu background was using the itemBackground attribute: <style name=”AppTheme” parent=”Theme.AppCompat.Light.DarkActionBar”> … <item name=”android:itemBackground”>@color/overflow_background</item> … </style> Tested from API 4.2 to 5.0.