xref: /aosp_15_r20/development/samples/XmlAdapters/_index.html (revision 90c8c64db3049935a07c6143d7fd006e26f8ecca)
1*90c8c64dSAndroid Build Coastguard Worker<p>This sample demonstrates the use of XML adapters.</p>
2*90c8c64dSAndroid Build Coastguard Worker
3*90c8c64dSAndroid Build Coastguard Worker<p>An XML Adapter is an XML file which defines the bindings between the data
4*90c8c64dSAndroid Build Coastguard Workerretrieved from a
5*90c8c64dSAndroid Build Coastguard Worker<a href="../../../reference/android/content/ContentProvider.html"><code>ContentProvider</code></a>
6*90c8c64dSAndroid Build Coastguard Workerand the different views of a layout. They are provided by the
7*90c8c64dSAndroid Build Coastguard Worker<a href="../../../reference/android/widget/Adapters.html"><code>Adapters</code></a>
8*90c8c64dSAndroid Build Coastguard Workerclass.</p>
9*90c8c64dSAndroid Build Coastguard Worker
10*90c8c64dSAndroid Build Coastguard WorkerThree list activities are provided which illustrate this:
11*90c8c64dSAndroid Build Coastguard Worker<ul>
12*90c8c64dSAndroid Build Coastguard Worker  <li><a href="src/com/example/android/xmladapters/ContactsListActivity.html"><strong>
13*90c8c64dSAndroid Build Coastguard Worker  ContactsListActivity</strong></a> uses the device's Contacts provider as its input source.
14*90c8c64dSAndroid Build Coastguard Worker  Contacts with a phone number are displayed, their photo being retrieved by a dedicated
15*90c8c64dSAndroid Build Coastguard Worker  <a href="src/com/example/android/xmladapters/ContactPhotoBinder.html"><code>ContactPhotoBinder
16*90c8c64dSAndroid Build Coastguard Worker  </code></a>.</li>
17*90c8c64dSAndroid Build Coastguard Worker
18*90c8c64dSAndroid Build Coastguard Worker  <li><a href="src/com/example/android/xmladapters/PhotosListActivity.html"><strong>
19*90c8c64dSAndroid Build Coastguard Worker  PhotosListActivity</strong></a> retrieves an RSS photo feed and displays the images and their
20*90c8c64dSAndroid Build Coastguard Worker  titles. The images are downloaded from the URL found in the feed using the
21*90c8c64dSAndroid Build Coastguard Worker  <a href="src/com/example/android/xmladapters/ImageDownloader.html"><code>ImageDownloader</code>
22*90c8c64dSAndroid Build Coastguard Worker  </a> helper class.</li>
23*90c8c64dSAndroid Build Coastguard Worker
24*90c8c64dSAndroid Build Coastguard Worker  <li><a href="src/com/example/android/xmladapters/RssReaderActivity.html"><strong>
25*90c8c64dSAndroid Build Coastguard Worker  RssReaderActivity</strong></a> also displays items extracted from an RSS feed. An additional
26*90c8c64dSAndroid Build Coastguard Worker  <a href="src/com/example/android/xmladapters/UrlIntentListener.html"><code>UrlIntentListener
27*90c8c64dSAndroid Build Coastguard Worker  </code></a> is used to open a browser when one of the news item is tapped.</li>
28*90c8c64dSAndroid Build Coastguard Worker</ul>
29*90c8c64dSAndroid Build Coastguard Worker
30*90c8c64dSAndroid Build Coastguard Worker<img alt="XmlPhotosAdapter" src="../images/XmlPhotosAdapter.png" />
31*90c8c64dSAndroid Build Coastguard Worker<img alt="XmlRssReader" src="../images/XmlRssReader.png" />
32