Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting Android Background & Persistence Menu Bar - Using attribute on older versions causes crash - Is there a theme /pattern approach?
    primarykey
    data
    text
    <p>In Android 3.0, the concept of "checked" can be rendered using an "activated" background. This gives you the persistent bar you see when you tap on a list fragment, providing context for the fragment to the list's right (e.g., tapping on a folder in Gmail highlights that folder and opens up another list fragment to show the conversations in that folder).</p> <p>For example, the fragment samples show stuff like:</p> <pre><code>setListAdapter(new ArrayAdapter&lt;String&gt;(getActivity(), android.R.layout.simple_list_item_activated_1, Shakespeare.TITLES)); </code></pre> <p>That resource (<code>android.R.layout.simple_list_item_activated_1</code>) is new to Android 3.0. What makes it "activated" is:</p> <pre><code>android:background="?android:attr/activatedBackgroundIndicator" </code></pre> <p>That attribute value is new to Android 3.0 and will cause you to crash if you try using it on earlier versions of Android, from what I can tell. I want to set the background to this magic value for the 3.0/large/landscape combination, and skip it otherwise.</p> <p>I can accomplish this by having two separate versions of the layout, one in a <code>-v11</code> resource set, one in a regular resource set. This is a bit less DRY than I'd like, though, since the bulk of the layout is the same, with only this one attribute either being included or being skipped.</p> <p>I took a stab at trying to use drawable resource aliases, so the <code>android:background</code> could refer to the alias and the alias would handle the <code>-v11</code> differentiation, but <code>&lt;bitmap&gt;</code> drawables don't seem to like <code>android:src="@null"</code>.</p> <p>I suspect there's a styles-and-themes approach to this problem, but since I've never fully wrapped my head around those (one of my more embarrassing Android knowledge gaps), I'm not completely sure what to do.</p> <p>Has anyone worked out a pattern for using "activated" on 3.0 and skipping it on pre-3.0, beyond separate layouts?</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload