로봇 전화번호부 4/4 UNIT 12 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 뷰 홀더 패턴을 사용할 수 있다. 토스트를 사용할 수 있다. 클릭 이벤트를 처리할 수 있다. 2.

Slides:



Advertisements
Similar presentations
Layout and Control in UI The user interface (UI) is the graphical interface user can see and interact with your app comprising UI controls like textbox,
Advertisements

@2011 Mihail L. Sichitiu1 Android Introduction Hello Views Part 1.
Cosc 4730 Android TabActivity and ListView. TabActivity A TabActivity allows for multiple “tabs”. – Each Tab is it’s own activity and the “root” activity.
Presenting Lists of Data. Lists of Data Issues involved – unknown number of elements – allowing the user to scroll Data sources – most common ArrayList.
Android development the first app. Andoid vs iOS which is better? Short answer: neither Proponents on both sides For an iOS side, see this article on.
Getting Started with Android APIs Ivan Wong. Motivation - “Datasheet” - Recently exposed to what’s available in Android - So let’s see what API’s are.
Android Tutorial Team 3 Jerry Yu Mayank Mandava Mu Du Will Wangles.
Package org.androidtown.database.query; import android.app.Activity; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase;
로봇 모니터링 2/2 UNIT 21 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Broadcasting Service 2.
@2011 Mihail L. Sichitiu1 Android Introduction GUI Menu Many thanks to Jun Bum Lim for his help with this tutorial.
CHAP 10. 고급 위젯. © 2012 생능출판사 All rights reserved 어댑터 뷰 어댑터 뷰 (AdapterView) 는 배열이나 파일, 데이터 베이스에 저장된 데이터를 화면에 표시할 때 유용한 뷰.
1/29/ Android Programming: FrameLayout By Dr. Ramji M. Makwana Professor and Head, Computer Engineering Department A.D. Patel.
ListView.
Create Navigation Drawer Team 2 Zhong Wang Jiaming Dong Philip Wu Lingduo Kong.
로봇을 조종하자 3/4 UNIT 17 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 스마트 폰의 센서를 사용할 수 있다. 2.
로봇 모션 편집기 4/4 UNIT 25 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 에디트 텍스트를 사용할 수 있다. 아이템을 삭제할 수 있다. 아이템을 편집할 수 있다. 2.
로봇 모니터링 1/2 UNIT 20 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Message Queue Handler 2.
Activity 생명주기 UNIT 13 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Logcat 액티비티 생명주기를 설명할 수 있다. 현재 상태를 저장할 수 있다. 2.
Custom Widget 1 UNIT 26 로봇 SW 콘텐츠 교육원 조용수. 캔버스 public void drawColor(int color) 2 public class ControllerView extends View { public ControllerView(Context.
1 Introducing Activity and Intent. 2 Memory LinearLayout, weight=2 LinearLayout, weight=1 TextView ListView.
데이터 저장 & Fragment UNIT 28 로봇 SW 콘텐츠 교육원 조용수. 데이터 저장 & Fragment SharedPreference 로 데이터 저장 Fragment 의 이해 2.
Copyright© Jeffrey Jongko, Ateneo de Manila University Custom ListAdapters.
네트워크 전송 1/2 UNIT 29 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Android Network 통신 2.
ListView and ExpandableListView
로봇을 조종하자 4/4 UNIT 18 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Intent Activity 호출 2.
Android and s Ken Nguyen Clayton state University 2012.
로봇을 조종하자 1/5 UNIT 14 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 터치 이벤트를 처리할 수 있다. 2.
Custom Widget 2 UNIT 27 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Custom Widget –Canvas 를 이용하여 Custom Widget 을 만든다. 2.
User Interface Layout Interaction. EventsEvent Handlers/Listeners Interacting with a user.
Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;
Cosc 4735 Activities, fragments, callbacks/listeners/interfaces.
Http :// developer. android. com / guide / topics / fundamentals. html.
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Cosc 5/4730 RecyclerView And more..
Lab7 – Appendix.
CS499 – Mobile Application Development
Android Layouts 8 May 2018 S.RENUKADEVI/AP/SCD/ANDROID LAYOUTS 1.
UNIT 11 로봇 전화번호부 3/4 로봇 SW 콘텐츠 교육원 조용수.
CS240: Advanced Programming Concepts
GUI Programming Fundamentals
Further android gui programming
ListView: Part 2.
CS499 – Mobile Application Development
Android Widgets 1 7 August 2018
Android Introduction Hello Views Part 1.
android architecture components with mvvm
Picasso Revisted.
CIS 470 Mobile App Development
Android Programming Lecture 6
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
UNIT 08 그림책 만들기 2/2 로봇 SW 콘텐츠 교육원 조용수.
BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight,
CMPE419 Mobile Application Development
滑動 建國科技大學 資管系 饒瑞佶.
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
ארועים ומאזינים android.
CMPE419 Mobile Application Development
Adding Components to Activity
BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2
Lasalle-App Tecnología Móvil.
Android Sensor Programming
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

로봇 전화번호부 4/4 UNIT 12 로봇 SW 콘텐츠 교육원 조용수

학습 목표 뷰 홀더 패턴을 사용할 수 있다. 토스트를 사용할 수 있다. 클릭 이벤트를 처리할 수 있다. 2

미션 3

너무 많은 아이템 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView listview = (ListView)findViewById(R.id.list); for(int i = 0; i < 100; ++i) { phones.add(new PhoneInfo(R.drawable.boy, " 갑돌이 " + i, " ")); phones.add(new PhoneInfo(R.drawable.boy, " 갑순이 " + i, " ")); } … }

뷰 홀더 패턴 5 private class ViewHolder { ImageView icon; TextView name; TextView phone; ImageView call; } Widget 할당 부분을 Tag 에 저장하여, 초기화 시간을 줄이는 방법

뷰 홀더 패턴 6 private class PhoneListAdapter extends ArrayAdapter public View getView(int position, View convertView, ViewGroup parent) public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if(convertView == null) { holder = new ViewHolder(); convertView = inflater.inflate(R.layout.listitem, null); convertView.setTag(holder); } else { holder = (ViewHolder)convertView.getTag(); } … return convertView; }

뷰 홀더 패턴 7 private class PhoneListAdapter extends ArrayAdapter public View getView(int position, View convertView, ViewGroup parent) public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if(convertView == null) { holder = new ViewHolder(); convertView = inflater.inflate(R.layout.listitem, null); holder.icon = (ImageView)convertView.findViewById(R.id.ivProfile); holder.call = (ImageView)convertView.findViewById(R.id.ivPhone); holder.name = (TextView)convertView.findViewById(R.id.tvText1); holder.phone = (TextView)convertView.findViewById(R.id.tvText0); convertView.setTag(holder); } else { holder = (ViewHolder)convertView.getTag(); } PhoneInfo info = (PhoneInfo)getItem(position); holder.name.setText(info.name); holder.phone.setText(info.phone); holder.icon.setImageResource(info.icon); return convertView; }

실습 8

버튼 이벤트 9 private class ViewHolder { ImageView icon; TextView name; TextView phone; ImageView call; }

버튼 이벤트 public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if(convertView == null) { holder = new ViewHolder(); convertView = inflater.inflate(R.layout.listitem, null); holder.icon = (ImageView)convertView.findViewById(R.id.ivProfile); holder.call = (ImageView)convertView.findViewById(R.id.ivPhone); holder.name = (TextView)convertView.findViewById(R.id.tvText1); holder.phone = (TextView)convertView.findViewById(R.id.tvText0); convertView.setTag(holder); } else { holder = (ViewHolder)convertView.getTag(); } PhoneInfo info = (PhoneInfo)getItem(position); holder.name.setText(info.name); holder.phone.setText(info.phone); holder.icon.setImageResource(info.icon); return convertView; }

버튼 이벤트 11 PhoneInfo info = (PhoneInfo)getItem(position); holder.name.setText(info.name); holder.phone.setText(info.phone); holder.icon.setImageResource(info.icon); holder.call.setOnClickListener(new View.OnClickListener() public void onClick(View v) { } });

토스트 Toast –public static Toast makeText(Context context, int resId, int duration) –public static final int LENGTH_SHORT –public static final int LENGTH_LONG –public void show() –public void cancel() 12

버튼 이벤트 13 PhoneInfo info = (PhoneInfo)getItem(position); holder.name.setText(info.name); holder.phone.setText(info.phone); holder.icon.setImageResource(info.icon); holder.call.setOnClickListener(new View.OnClickListener() public void onClick(View v) { Toast.makeText(getContext(), info.phone, Toast.LENGTH_SHORT).show(); } });

아이템 클릭 이벤트 14 final PhoneInfo info = (PhoneInfo)getItem(position); holder.name.setText(info.name); holder.phone.setText(info.phone); holder.icon.setImageResource(info.icon); holder.call.setOnClickListener(new View.OnClickListener() public void onClick(View v) { Toast.makeText(getContext(), "Button "+info.phone, Toast.LENGTH_SHORT).show(); } }); convertView.setOnClickListener(new View.OnClickListener() public void onClick(View v) { Toast.makeText(getContext(), "View "+info.name, Toast.LENGTH_SHORT).show(); } }); return convertView;

아이템 배경색 res/drawable/selection_list_item.xml 15 <item android:state_enabled="true" android:state_pressed="false" android:state_focused="true" /> <item android:state_enabled="true" android:state_pressed="true" /> <item android:state_enabled="true" /> <item android:state_enabled="false" />

아이템 배경색 res/values/colors.xml 16 #ff #ffff7a00 #ffed1624 #ff989898

아이템 클릭 이벤트 17 <LinearLayout xmlns:android=" android:orientation="horizontal" android:layout_width="match_parent" android:gravity="center_vertical" android:padding="6dp" android:descendantFocusability="blocksDescendants" android:layout_height="60dp">

실습 18