{"id":1187,"date":"2019-04-08T22:05:51","date_gmt":"2019-04-08T13:05:51","guid":{"rendered":"https:\/\/www.charlezz.com\/?p=1187"},"modified":"2019-04-08T22:06:12","modified_gmt":"2019-04-08T13:06:12","slug":"%ec%96%b8%ec%96%b4-%eb%b3%80%ea%b2%bd%ea%b3%bc-androidviewmodel-%ec%95%88%ed%8b%b0%ed%8c%a8%ed%84%b4","status":"publish","type":"post","link":"https:\/\/charlezz.com\/?p=1187","title":{"rendered":"\uc5b8\uc5b4 \ubcc0\uacbd\uacfc AndroidViewModel \uc548\ud2f0\ud328\ud134"},"content":{"rendered":"<p>https:\/\/medium.com\/androiddevelopers\/locale-changes-and-the-androidviewmodel-antipattern-84eb677660d9\uc744 \ubc88\uc5ed\ud55c \uae00\uc785\ub2c8\ub2e4.<\/p>\n<hr \/>\n<p><a href=\"https:\/\/www.charlezz.com\/?attachment_id=1189\" rel=\"attachment wp-att-1189\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.charlezz.com\/wordpress\/wp-content\/uploads\/2019\/04\/0_kL5zW7zi_ImPUwHr.png\" alt=\"\" width=\"951\" height=\"719\" class=\"aligncenter size-full wp-image-1189\" srcset=\"https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2019\/04\/0_kL5zW7zi_ImPUwHr.png 951w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2019\/04\/0_kL5zW7zi_ImPUwHr-300x227.png 300w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2019\/04\/0_kL5zW7zi_ImPUwHr-768x581.png 768w\" sizes=\"(max-width: 951px) 100vw, 951px\" \/><\/a><\/p>\n<p>ViewModel\uc740 \ud654\uba74\ud68c\uc804\uc774\ub098 \uc5b8\uc5b4 \ubcc0\uacbd\uc5d0 \uc758\ud55c \uc561\ud2f0\ube44\ud2f0 \uc7ac\uc0dd\uc131\uc5d0\uc11c\ub3c4 \ub2e4\uc2dc \uc0dd\uc131\ub418\uc9c0 \uc54a\uace0 \uc774\uc804 \uc778\uc2a4\ud134\uc2a4\uac00 \uadf8\ub300\ub85c \ub0a8\uc544 \uc720\uc9c0 \ub418\ub294 \ud2b9\uc9d5\uc774 \uc788\uc2b5\ub2c8\ub2e4. \uc2dc\uc2a4\ud15c \uc5b8\uc5b4 \ubcc0\uacbd\uc744 \ud558\uae30\uc804\uc5d0 \uc544\ub798\uc758 ViewModel\ucf54\ub4dc\ub97c \ubcf4\ub3c4\ub85d \ud558\uacd8\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"lang:java decode:true\">\/\/\uc774\ub807\uac8c \ucf54\ub4dc\ub97c \uc9dc\uc9c0 \ub9c8\uc138\uc694\r\npublic class MyViewModel extends AndroidViewModel {\r\n    public final MutableLiveData&lt;String&gt; statusLabel = new MutableLiveData&lt;&gt;();\r\n    \r\n    public SampleViewModel(Application context) {\r\n        super(context);\r\n        statusLabel.setValue(context.getString(R.string.labelString));\r\n    }\r\n}<\/pre>\n<p>\uc774 \ucf54\ub4dc\uc758 \ubb38\uc81c\ub294 \ubb38\uc790\uc5f4\uc774 \uc0dd\uc131\uc790\uc5d0\uc11c\ub9cc \uacb0\uc815\ub41c\ub2e4\ub294 \uac83\uc785\ub2c8\ub2e4. \uc2dc\uc2a4\ud15c \uc5b8\uc5b4\ubcc0\uacbd\uc774 \ubc1c\uc0dd\ud574\ub3c4 ViewModel\uc740 \uc7ac\uc0dd\uc131 \ub418\uc9c0 \uc54a\uc8e0. \uadf8\ub7ec\uba74 \ubb38\uc790\uc5f4\ub3c4 \ub2e4\uad6d\uc5b4 \uc9c0\uc6d0\uc774 \ub418\uc9c0 \uc54a\uc744\uac83\uc785\ub2c8\ub2e4.<\/p>\n<p>\uc774\ub97c \ud574\uacb0\ud560 \ub2e4\ub978 \ubc29\ubc95\uc740 \ub9ac\uc18c\uc2a4\uc758 ID\ub97c \ud65c\uc6a9\ud558\ub294 \uac83\uc785\ub2c8\ub2e4.\u00a0<\/p>\n<pre class=\"lang:java decode:true\">\/\/String \ub300\uc2e0 \ub9ac\uc18c\uc2a4 ID\ub97c \ub178\ucd9c\uc2dc\ud0b5\ub2c8\ub2e4.\r\npublic class MyViewModel extends ViewModel {\r\n    public final MutableLiveData&lt;Int&gt; statusLabel = new MutableLiveData&lt;&gt;();\r\n    \r\n    public SampleViewModel(Application context) {\r\n        super(context);\r\n        statusLabel.setValue(R.string.labelString);\r\n    }\r\n}<\/pre>\n<p>\ub9ac\uc18c\uc2a4 ID\ub97c \ub178\ucd9c\uc2dc\ud0a8\ub4a4 \uc561\ud2f0\ube44\ud2f0\uac00 \uc7ac\uc0dd\uc131 \ub418\uc5c8\uc744 \ub54c View\uac00 \ub9ac\uc18c\uc2a4 ID\ub97c \ucc38\uc870\ud558\uc5ec \uc62c\ubc14\ub978 \uad6d\uac00 \ucf54\ub4dc\uc758 \ub9ac\uc18c\uc2a4\ub97c \ucc38\uc870\ud560\uc218 \uc788\ub3c4\ub85d \ud569\ub2c8\ub2e4. DataBinding \uac19\uc740 \ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \uc0ac\uc6a9\ud55c\ub2e4\uba74 \ub808\uc774\uc544\uc6c3\uc5d0 Data\uac00 \ubc14\uc778\ub529 \ub420\ub54c \uc62c\ubc14\ub978 \ub9ac\uc18c\uc2a4\uac00 \uacb0\uc815 \ub420 \uc218 \uc788\ub3c4\ub85d \ub3c4\uc640\uc904 \uac83\uc785\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/medium.com\/androiddevelopers\/locale-changes-and-the-androidviewmodel-antipattern-84eb677660d9\uc744 \ubc88\uc5ed\ud55c \uae00\uc785\ub2c8\ub2e4. ViewModel\uc740 \ud654\uba74\ud68c\uc804\uc774\ub098 \uc5b8\uc5b4 \ubcc0\uacbd\uc5d0 \uc758\ud55c \uc561\ud2f0\ube44\ud2f0 \uc7ac\uc0dd\uc131\uc5d0\uc11c\ub3c4 \ub2e4\uc2dc \uc0dd\uc131\ub418\uc9c0 \uc54a\uace0 \uc774\uc804 \uc778\uc2a4\ud134\uc2a4\uac00 \uadf8\ub300\ub85c \ub0a8\uc544 \uc720\uc9c0 \ub418\ub294 \ud2b9\uc9d5\uc774 \uc788\uc2b5\ub2c8\ub2e4. \uc2dc\uc2a4\ud15c \uc5b8\uc5b4 \ubcc0\uacbd\uc744 \ud558\uae30\uc804\uc5d0 \uc544\ub798\uc758 ViewModel\ucf54\ub4dc\ub97c \ubcf4\ub3c4\ub85d \ud558\uacd8\uc2b5\ub2c8\ub2e4. \/\/\uc774\ub807\uac8c \ucf54\ub4dc\ub97c \uc9dc\uc9c0 \ub9c8\uc138\uc694 public class MyViewModel extends AndroidViewModel { public final MutableLiveData&lt;String&gt; statusLabel = new MutableLiveData&lt;&gt;(); public SampleViewModel(Application context) { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[25],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/1187"}],"collection":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1187"}],"version-history":[{"count":2,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/1187\/revisions"}],"predecessor-version":[{"id":1190,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/1187\/revisions\/1190"}],"wp:attachment":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}