Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Viewの再利用方法まとめ

konifar
March 12, 2015

 Viewの再利用方法まとめ

potatotips#15でのLTです。
http://connpass.com/event/12140/

konifar

March 12, 2015
Tweet

More Decks by konifar

Other Decks in Programming

Transcript

  1. ESBXBCMF <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.~~android"> ! <item android:state_pressed="true"> <shape

    android:shape="rectangle"> <solid android:color="#0a000000" /> </shape> </item> ! </selector>
  2. ESBXBCMF <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.~~android"> ! <item android:state_pressed="true"> <shape

    android:shape="rectangle"> <solid android:color="#0a000000" /> </shape> </item> ! </selector> ࢖͑ΔTUBUF͸ɺ4UBUF-JTU%SBXBCMFͷϖʔδࢀরɻ
  3. TUZMFTYNM <TextView style="@style/TextSub" android:layout_width="match_parent" android:layout_height="wrap_content" /> <style name="TextSub"> <item name="android:textSize">@dimen/text_small</item>

    <item name="android:textColor">@color/grey600</item> <item name=“android:gravity">center_vertical</item> <item name="android:maxLines">2</item> </style>
  4. JODMVEF <RelativeLayout android:layout_width="match_parent" android:layout_height=“wrap_content”> ! <ImageView … /> ! <RelativeLayout

    android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView … /> <TextView … /> <TextView … /> </RelativeLayout> ! </RelativeLayout>
  5. JODMVEF <RelativeLayout android:layout_width="match_parent" android:layout_height=“wrap_content”> ! <ImageView … /> ! <RelativeLayout

    android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView … /> <TextView … /> <TextView … /> </RelativeLayout> ! </RelativeLayout>
  6. JODMVEF <RelativeLayout android:layout_width="match_parent" android:layout_height=“wrap_content”> ! <ImageView … /> ! <include

    layout=“@layout/part_character_info" /> ! </RelativeLayout> 7JFXͷωετ͕ଟ͘ͳΓ͕ͪͳͷͰɺNFSHFͷ࢖͍ํΛ֮͑ͯ ͓͘ͱΑ͍ɻ 㱺8IBUJTUIFQVSQPTFPG"OESPJETUBHJO9.-MBZPVUT
  7. $VTUPN7JFX public class WordBalloonView extends RelativeLayout { ... public WordBalloonView(Context

    context, AttributeSet attrs) { super(context, attrs); inflate(context, R.layout.ui_word_balloon, this); ButterKnife.inject(this); ! TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.WordBalloonView); try { balloonText = a.getString( R.styleable.WordBalloonView_balloonText); } finally { a.recycle(); } ! mTxtBalloon.setText(balloonText); } ! public void setBalloonText(String balloonText) { mTxtBalloon.setText(balloonText); } }
  8. $VTUPN7JFX public class WordBalloonView extends RelativeLayout { ... public WordBalloonView(Context

    context, AttributeSet attrs) { super(context, attrs); inflate(context, R.layout.ui_word_balloon, this); ButterKnife.inject(this); ! TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.WordBalloonView); try { balloonText = a.getString( R.styleable.WordBalloonView_balloonText); } finally { a.recycle(); } ! mTxtBalloon.setText(balloonText); } ! public void setBalloonText(String balloonText) { mTxtBalloon.setText(balloonText); } }
  9. $VTUPN7JFX public class WordBalloonView extends RelativeLayout { ... public WordBalloonView(Context

    context, AttributeSet attrs) { super(context, attrs); inflate(context, R.layout.ui_word_balloon, this); ButterKnife.inject(this); ! TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.WordBalloonView); try { balloonText = a.getString( R.styleable.WordBalloonView_balloonText); } finally { a.recycle(); } ! mTxtBalloon.setText(balloonText); } ! public void setBalloonText(String balloonText) { mTxtBalloon.setText(balloonText); } }
  10. $VTUPN7JFX public class WordBalloonView extends RelativeLayout { ... public WordBalloonView(Context

    context, AttributeSet attrs) { super(context, attrs); inflate(context, R.layout.ui_word_balloon, this); ButterKnife.inject(this); ! TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.WordBalloonView); try { balloonText = a.getString( R.styleable.WordBalloonView_balloonText); } finally { a.recycle(); } ! mTxtBalloon.setText(balloonText); } ! public void setBalloonText(String balloonText) { mTxtBalloon.setText(balloonText); } }
  11. $VTUPN7JFX public class WordBalloonView extends RelativeLayout { ... public WordBalloonView(Context

    context, AttributeSet attrs) { super(context, attrs); inflate(context, R.layout.ui_word_balloon, this); ButterKnife.inject(this); ! TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.WordBalloonView); try { balloonText = a.getString( R.styleable.WordBalloonView_balloonText); } finally { a.recycle(); } ! mTxtBalloon.setText(balloonText); } ! public void setBalloonText(String balloonText) { mTxtBalloon.setText(balloonText); } }
  12. ·ͱΊ EJNFOTYNM DPMPSTYNM ESBXBCMFYNM Կ౓΋ग़ͯ͘Δ ϨΠΞ΢τ͔ TUZMFTYNM JODMVEF $VTUPN7JFX ෳ਺ͷ7JFXͰ

    ߏ੒͞Ε͍ͯΔ͔ ϩδοΫؚ͕· ΕΔ͔ ϨΠΞ΢τYNMʹ௚઀هड़ /P :FT /P :FT /P :FT σβΠϯʹ߹Θͤͯ࢖༻