I have a fragment with Recycler view
View view = inflater.inflate(R.layout.recyclerview, container, false);
ViewGroup fragmentview=(ViewGroup)getView();
dashboardcontentList = new ArrayList<>();
adapter = new DashboardAdapter(getActivity().getApplicationContext(), dashboardcontentList);
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
Recycler view is inflated properly but I have a pop menu in each card of the recycler view.
But the popup menu binder is throwing a infateException
@Override
public void onBindViewHolder(final MyViewHolder holder, int position) {
dashboardcontent dashboardcontent = dashboardcontentList.get(position);
holder.title.setText(dashboardcontent.getName());
Glide.with(mContext).load(dashboardcontent.getThumbnail()).into(holder.thumbnail);
holder.overflow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPopupMenu(holder.overflow);
}
});
}
/**
* Showing popup menu when tapping on 3 dots
*/
private void showPopupMenu(View view) {
// inflate menu
PopupMenu popup = new PopupMenu(mContext, view);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.menu_album, popup.getMenu());
popup.setOnMenuItemClickListener(new MyMenuItemClickListener());
try{
popup.show();}
catch (Exception e){
e.printStackTrace();
}
}
The same adapter when its called from another activity (Homeactivity) popup menu works fine but from the fragment(contained in welcomeactivity) it is throwing inflate exception.
AndroidManifest file
<application
android:name=".medipal.App"
android:allowBackup="true"
android:debuggable="true"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".activity.HomeActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activity.Welcome"
android:label="@string/title_activity_welcome"
android:theme="@style/AppTheme" android:parentActivityName=".activity.HomeActivity" />
<activity android:name=".activity.HelpScreen" />
<activity android:name=".activity.Recyclerview"
android:label="Recyclerview"
android:theme="@style/AppTheme">
</activity>
<activity android:name=".activity.contacts">
</manifest>
I expect the output to be something like when the menu button is clicked I see a crash
a
ndroid.view.InflateException: Binary XML file line #17: Failed to resolve attribute at index 6: TypedValue{t=0x3/d=0x379 "res/drawable/ic_menu_moreoverflow_material.xml" a=1 r=0x10803d9}
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.support.v7.view.menu.MenuAdapter.getView(MenuAdapter.java:93)
at android.support.v7.view.menu.MenuPopup.measureIndividualMenuWidth(MenuPopup.java:160)
at android.support.v7.view.menu.StandardMenuPopup.tryShow(StandardMenuPopup.java:153)
at android.support.v7.view.menu.StandardMenuPopup.show(StandardMenuPopup.java:187)
at android.support.v7.view.menu.MenuPopupHelper.showPopup(MenuPopupHelper.java:290)
at android.support.v7.view.menu.MenuPopupHelper.tryShow(MenuPopupHelper.java:175)
at android.support.v7.view.menu.MenuPopupHelper.show(MenuPopupHelper.java:141)
at android.support.v7.widget.PopupMenu.show(PopupMenu.java:233)