이곳엔 기본 템플릿 외에 유용한 템플릿이 추가되어있다.
- 압축푼 파일을 sdk-folder/extras/templates/ 에 있는 activities 와 others 폴더에 각각 넣는다.
(난 sdk-folder/tools/templates/ 에 있었음) - New->Other ->Android->Android Object
템플릿들
- EfficientListAdapter
매번 리스트를 만드려면 view holder 패턴을 작성해야되는데 이를 편리하게 하여준다
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characterspublic class ItemAdapter extends BaseAdapter { // TODO replace with a collection of real data private static final List<DummyItem> DATA = DummyItemContent.ITEMS; private LayoutInflater mInflater; public ItemAdapter(Context context) { // Cache the LayoutInflate to avoid asking for a new one each time. mInflater = LayoutInflater.from(context); } /** * @see android.widget.ListAdapter#getCount() */ public int getCount() { return DATA.size(); } /** * @see android.widget.ListAdapter#getItem(int) */ public Object getItem(int position) { return DATA.get(position); } /** * Use the array index as a unique id. * * @see android.widget.ListAdapter#getItemId(int) */ public long getItemId(int position) { return position; } /** * Make a view to hold each row. * * @see android.widget.ListAdapter#getView(int, android.view.View, * android.view.ViewGroup) */ public View getView(int position, View convertView, ViewGroup parent) { // A ViewHolder keeps references to children views to avoid unneccessary // calls // to findViewById() on each row. ViewHolder holder; // When convertView is not null, we can reuse it directly, there is no // need // to reinflate it. We only inflate a new View when the convertView // supplied // by ListView is null. if (convertView == null) { convertView = mInflater.inflate(R.layout.list_item_item, parent, false); // Creates a ViewHolder and store references to the two children // views // we want to bind data to. holder = new ViewHolder(); // TODO store references to your views holder.title = (TextView) convertView.findViewById(R.id.title); holder.subtitle = (TextView) convertView .findViewById(R.id.subtitle); holder.thumbnail = (ImageView) convertView .findViewById(R.id.thumbnail); convertView.setTag(holder); } else { // Get the ViewHolder back to get fast access to the TextView // and the ImageView. holder = (ViewHolder) convertView.getTag(); } // TODO Bind your data efficiently with the holder. holder.title.setText(DATA.get(position).content); holder.subtitle.setText(DATA.get(position).content); holder.thumbnail.setImageResource(DATA.get(position).thumbnail); return convertView; } static class ViewHolder { // TODO define members for each view in the item layout TextView title; TextView subtitle; ImageView thumbnail; } } - ParcelableType
Parcelable 클래스 템플릿This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characterspublic class NameCard implements Parcelable { // TODO declare your real class members // Members must be either primitives, primitive arrays or parcelables private int mFoo; private String mBar; // TODO implement your constructors, getters & setters, methods private NameCard(Parcel in) { // TODO read your class members from the parcel // Note: order is important - you must read in the same order // you write in writeToParcel! mFoo = in.readInt(); mBar = in.readString(); } @Override public void writeToParcel(Parcel out, int flags) { // TODO write your class members to the parcel // Note: order is important - you must write in the same order // you read in your private parcelable constructor! out.writeInt(mFoo); out.writeString(mBar); } @Override public int describeContents() { // TODO return Parcelable.CONTENTS_FILE_DESCRIPTOR if your class members // include a FileDescriptor, otherwise you can simply return 0 return 0; } public static final Parcelable.Creator<NameCard> CREATOR = new Parcelable.Creator<NameCard>() { public NameCard createFromParcel(Parcel in) { return new NameCard(in); } public NameCard[] newArray(int size) { return new NameCard[size]; } }; } - Sherlock 템플릿들
기본 activity 와 같은 템플릿으로 Sherlock 라이브러리를 사용하여 생성 - TVLeftNavBarActivity
google TV 를 위한 것이라고 한다. 원문참고
This template creates a new blank activity with a left navigation/action bar implementation optimized for Google TV. You can select different visual behaviors (expanded, collapsed, or expand on focus) and navigation modes (standard, tabs or list). This template has a dependency on the Google TV LeftNavBarLibrary project which is available here.
댓글 없음:
댓글 쓰기