Basically I want to set my activity's theme in the manifest as follows:
android:theme="@android:style/Theme.Translucent.NoTitleBar"
And I want my activity to load up a ListFragment with the theme, Theme.Holo.Dialog (defined in my own style), however I can't just call setStyle(....) in my fragment as I could if it were a DialogFragment.
I believe that I should be able to use a ContextThemeWrapper but I'm having trouble understanding the calls I need to make. So far in my onCreateView I have:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
LayoutInflater newInflater = inflater.cloneInContext(new ContextThemeWrapper(getActivity(), R.style.DialogThemeSelector));
View inflatedView = newInflater.inflate(R.layout.favourites_print, container, false);
.....
But this is not working. Thanks in advance. Peter.
*Edit * Posting style:
<style name="DialogThemeSelector" parent="@android:style/Theme.Holo.Dialog"/>
Try getting a new LayoutInflater
instead of converting the provided one, like so:
Context newContext = new ContextThemeWrapper(getActivity(), R.style.DialogThemeSelector);
LayoutInflater newInflater = (LayoutInflater) newContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View inflatedView = newInflater.inflate(R.layout.favourites_print, container, false);
If that doesn't work, I would suspect that there may be something missing in your style
.
I just do it the naive way: I define my list item layouts in XML, using the style
attribute, and it seems to work. My list items are not so much concerned with whether they are in a fragment or not. I have not tried styling the fragment itself, but since the list items are the only thing in it, styling them seems sufficient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With