Android Programming The Big Nerd Ranch Guide, 3rd Edition

(Brent) #1
Defining a menu in XML

255

Back on the main screen, click Next to move to the last step of the wizard. The Asset Studio will show
you a preview of the work that it will do (Figure 13.7). Notice that an hdpi, mdpi, xhdpi, and xxhdpi
icon will be created for you. Jim-dandy.


Figure 13.7  Asset Studio’s generated files


Select Finish to generate the images. Then, in your layout file, modify your icon attribute to reference
the new resource in your project.


Listing 13.5  Referencing a local resource
(res/menu/fragment_crime_list.xml)


<item
android:id="@+id/new_crime"
android:icon="@android:drawable/ic_menu_add"
android:icon="@drawable/ic_menu_add"
android:title="@string/new_crime"
app:showAsAction="ifRoom|withText"/>


http://www.ebook3000.com

Free download pdf