ºÇ½ª¹¹¿·¡§
t_yokky2002 2011ǯ09·î05Æü(·î) 19:24:30ÍúÎò
¤³¤Î±é½¬¤Ç¤Ï¡¢°Ê²¼¤Î¥×¥í¥¸¥§¥¯¥È¤ò»ÈÍѤ·¤Þ¤¹¡£
Eclipse¤Ë¥¤¥ó¥Ý¡¼¥È¤·¤Æ¤¯¤À¤µ¤¤¡£
Eclipse¤Ë¥¤¥ó¥Ý¡¼¥È¤·¤Æ¤¯¤À¤µ¤¤¡£
¥×¥í¥¸¥§¥¯¥È | practice_resource.zip |
ʸ»úÎó¤òÀßÄꤹ¤ëÄêµÁ¥Õ¥¡¥¤¥ë¡Êres/values/strings.xml¡Ë¤Ë¡¢ÄêµÁ¤òµ½Ò¤·¤Þ¤¹¡£ ÅÀÀþÆâ¤ÎÆâÍƤòÄɵ¤·¤Æ¤¯¤À¤µ¤¤¡£ Äɵ¤¬½ª¤ï¤Ã¤¿¤é¼Â¹Ô¤·¡¢¡ÖÃ͡פò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£Àµ¤·¤¯É½¼¨¤µ¤ì¤Þ¤·¤¿¤«¡©
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, resource practice</string> <string name="app_name">¥ê¥½¡¼¥¹±é½¬</string> <!-- ¢¤³¤³¤«¤é --> <string name="message1">¥á¥Ã¥»¡¼¥¸£±</string> <string name="message2">¥á¥Ã¥»¡¼¥¸£²</string> <!-- ¢¬¤³¤³¤Þ¤Ç --> </resources>
¼¡¤Ë¡¢¥ì¥¤¥¢¥¦¥ÈXML¥Õ¥¡¥¤¥ë¡Êres/layout/values.xml¡Ë¤Ë¡¢ÄêµÁ¤òµ½Ò¤·¤Þ¤¹¡£ ÅÀÀþÆâ¤ÎÆâÍƤòÄɵ¤·¤Æ¤¯¤À¤µ¤¤¡£
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <!-- ¢¤³¤³¤«¤é --> <TextView android:id="@+id/textView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/message1" /> <TextView android:id="@+id/textView2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/message2" /> <!-- ¢¬¤³¤³¤Þ¤Ç --> </LinearLayout>
¿§¤òÀßÄꤹ¤ëÄêµÁ¥Õ¥¡¥¤¥ë¡Êres/values/colors.xml¡Ë¤Ë¡¢¿§¤ÎÄêµÁ¤òµ½Ò¤·¤Þ¤¹¡£ ÅÀÀþÆâ¤ÎÆâÍƤòÄɵ¤·¤Æ¤¯¤À¤µ¤¤¡£ Äɵ¤¬½ª¤ï¤Ã¤¿¤é¼Â¹Ô¤·¡¢¡ÖÃ͡פò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£Àµ¤·¤¯É½¼¨¤µ¤ì¤Þ¤·¤¿¤«¡©res/values¤È¤¤¤¦¥Õ¥©¥ë¥À¤ò±¦¥¯¥ê¥Ã¥¯¤·¤Æ¡¢¡Ö¿·µ¬¡×->¡ÖAndroid XML¥Õ¥¡¥¤¥ë¡×¤òÁªÂò¤·¡¢colors.xml¤òºîÀ®¤·¤Æ¤¯¤À¤µ¤¤¡£
¹àÌÜ | ÆâÍÆ |
---|---|
¥×¥í¥¸¥§¥¯¥È | practice_resource |
¥Õ¥¡¥¤¥ë | colors.xml |
What type of resource would you like to create? | ÃÍ |
¥Õ¥©¥ë¥À | /res/values |
<?xml version="1.0" encoding="utf-8"?> <resources> <!-- ¢¤³¤³¤«¤é --> <color name="bg_gray">#909090</color> <color name="bg_red">#FF0000</color> <color name="bg_blue">#0000FF</color> <!-- ¢¬¤³¤³¤Þ¤Ç --> </resources>
res/layout/values.xml¥Õ¥¡¥¤¥ë¤ò³«¤¡¢ÅÀÀþ¤ÎÆâÍƤòÄɵ¤·¤Æ¤¯¤À¤µ¤¤¡£
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" <!-- ¢¤³¤³¤«¤é --> android:background="@color/bg_gray"> <!-- ¢¬¤³¤³¤Þ¤Ç --> <TextView android:id="@+id/textView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/message1" <!-- ¢¤³¤³¤«¤é --> android:background="@color/bg_red" /> <!-- ¢¬¤³¤³¤Þ¤Ç --> <TextView android:id="@+id/textView2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/message2" <!-- ¢¤³¤³¤«¤é --> android:background="@color/bg_blue" /> <!-- ¢¬¤³¤³¤Þ¤Ç --> </LinearLayout>
res/values¥Õ¥©¥ë¥À¤ò±¦¥¯¥ê¥Ã¥¯¤·¤Æ¡¢¡Ö¿·µ¬¡×->¡ÖAndroid XML¥Õ¥¡¥¤¥ë¡×¤òÁªÂò¤·¡¢dimens.xml¤òºîÀ®¤·¤Æ¤¯¤À¤µ¤¤¡£
¹àÌÜ | ÆâÍÆ |
---|---|
¥×¥í¥¸¥§¥¯¥È | practice_resource |
¥Õ¥¡¥¤¥ë | dimens.xml |
What type of resource would you like to create? | ÃÍ |
¥Õ¥©¥ë¥À | /res/values |
¥Õ¥©¥ó¥È¤ÎÂ礤µ¤òÀßÄꤹ¤ëÄêµÁ¥Õ¥¡¥¤¥ë¡Êres/values/dimens.xml¡Ë¤òµ½Ò¤·¤Þ¤¹¡£ ÅÀÀþÆâ¤ÎÆâÍƤòÄɵ¤·¤Æ¤¯¤À¤µ¤¤¡£ Äɵ¤¬½ª¤ï¤Ã¤¿¤é¼Â¹Ô¤·¡¢¡ÖÃ͡פò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£Àµ¤·¤¯É½¼¨¤µ¤ì¤Þ¤·¤¿¤«¡©
<?xml version="1.0" encoding="utf-8"?> <resources> <!-- ¢¤³¤³¤«¤é --> <dimen name="font_size_20">20dip</dimen> <!-- ¢¬¤³¤³¤Þ¤Ç --> </resources>
res/layout/values.xml¥Õ¥¡¥¤¥ë¤ò³«¤¡¢ÅÀÀþ¤ÎÆâÍƤòÄɵ¤·¤Æ¤¯¤À¤µ¤¤¡£
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/bg_white"> <TextView android:id="@+id/textView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/message1" android:background="@color/bg_red" /> <TextView android:id="@+id/textView2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/message2" <!-- ¢¤³¤³¤«¤é --> android:textSize="@dimen/font_size_20" <!-- ¢¬¤³¤³¤Þ¤Ç --> android:background="@color/bg_blue" /> </LinearLayout>
¤³¤³¤Þ¤Ç¤Î½¤Àµ¤Ç¡¢°Ê²¼¤ÎÍͤ˲èÌÌɽ¼¨¤µ¤ì¤Æ¤¤¤ì¤Ð¡¢ÌäÂꤢ¤ê¤Þ¤»¤ó¡£
![](https://image01.seesaawiki.jp/a/r/androider/5cb5d2366e8d339f.png)
res/layout¥Õ¥©¥ë¥À¤ò±¦¥¯¥ê¥Ã¥¯¤·¤Æ¡¢¡Ö¿·µ¬¡×->¡ÖAndroid XML¥Õ¥¡¥¤¥ë¡×¤òÁªÂò¤·¡¢image.xml¤òºîÀ®¤·¤Æ¤¯¤À¤µ¤¤¡£
¹àÌÜ | ÆâÍÆ |
---|---|
¥×¥í¥¸¥§¥¯¥È | practice_resource |
¥Õ¥¡¥¤¥ë | image.xml |
What type of resource would you like to create? | ¥ì¥¤¥¢¥¦¥È |
¥Õ¥©¥ë¥À | /res/layout |
Select the root element for the XML file | LinearLayout |
¥ì¥¤¥¢¥¦¥ÈÄêµÁ¥Õ¥¡¥¤¥ë¡Êres/values/image.xml¡Ë¤òµ½Ò¤·¤Þ¤¹¡£ ÅÀÀþÆâ¤ÎÆâÍƤòÄɵ¤·¤Æ¤¯¤À¤µ¤¤¡£ Äɵ¤¬½ª¤ï¤Ã¤¿¤é¼Â¹Ô¤·¡¢¡Ö²èÁü¡×¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£Àµ¤·¤¯É½¼¨¤µ¤ì¤Þ¤·¤¿¤«¡©
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center"> <!-- ¢¤³¤³¤«¤é --> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android" /> <!-- ¢¬¤³¤³¤Þ¤Ç --> </LinearLayout>
¼¡¤Ë¡¢ÇØ·Ê¿§¤òÊѹ¹¤·¤Þ¤¹¡£ res/values/colors.xml¡¢res/layout/image.xml¤Ë¡¢ÅÀÀþÆâ¤òÄɵ¤·¤Æ¤¯¤À¤µ¤¤¡£res/values/colors.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="bg_gral">#909090</color> <color name="bg_red">#FF0000</color> <color name="bg_blue">#0000FF</color> <!-- ¢¤³¤³¤«¤é --> <color name="bg_green">#00FF00</color> <!-- ¢¬¤³¤³¤Þ¤Ç --> </resources>res/layout/image.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" <!-- ¢¤³¤³¤«¤é --> android:background="@color/bg_green"> <!-- ¢¬¤³¤³¤Þ¤Ç --> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android" /> </LinearLayout>
¤³¤³¤Þ¤Ç¤Î½¤Àµ¤Ç¡¢°Ê²¼¤ÎÍͤ˲èÌÌɽ¼¨¤µ¤ì¤Æ¤¤¤ì¤Ð¡¢ÌäÂꤢ¤ê¤Þ¤»¤ó¡£
![](https://image02.seesaawiki.jp/a/r/androider/ead57b1ee5f12000.png)
¤³¤Î¥Ú¡¼¥¸¤Ø¤Î¥³¥á¥ó¥È
fY9vt7 Great post.Much thanks again. Really Cool.
EJvXIf Im grateful for the blog article.Really looking forward to read more. Keep writing.
47VfrL <a href="http://rulnalzaoifr.com/">rulnalzaoifr</a>, [url=http://htuoeurhixue.com/]htuoeurhixue[/url], [link=http://kwqyxgjyribn.com/]kwqyxgjyribn[/link], http://rjkxughzwobb.com/
Fb0xGX <a href="http://kimqcjcxzdsa.com/">kimqcjcxzdsa</a>, [url=http://yythjbjabijd.com/]yythjbjabijd[/url], [link=http://mdmzwiupomlu.com/]mdmzwiupomlu[/link], http://caspzxsotjas.com/