res/values/string.xml 을 셋팅 해준다...
하나를 만들고 xml화면으로 가서 나머지 날코딩 하자~
생성하면 R.java파일에 주소값이 만들어 졌는지 확인 해보자~~
<?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:orientation="vertical" > <Spinner android:id="@+id/spinner1" android:layout_width="match_parent" android:layout_height="wrap_content" /> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/red" /> </LinearLayout>strings.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, TwinAnimaionActivity!</string> <string name="app_name">14.TwinAnimaion</string> <string-array name="twin"> <item >ani0</item> <item >ani1</item> <item >ani2</item> <item >ani3</item> <item >ani4</item> <item >ani5</item> <item >ani6</item> </string-array> </resources>R.java
package com.gusfree.twinanimation; public final class R { public static final class array { public static final int twin=0x7f050000; } public static final class attr { } public static final class drawable { public static final int ic_launcher=0x7f020000; public static final int red=0x7f020001; } public static final class id { public static final int imageView1=0x7f060001; public static final int spinner1=0x7f060000; } public static final class layout { public static final int main=0x7f030000; } public static final class string { public static final int app_name=0x7f040001; public static final int hello=0x7f040000; } }
package com.gusfree.twinanimation; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.animation.TranslateAnimation; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.Spinner; import android.widget.Toast; public class TwinAnimaionActivity extends Activity { Spinner spinner; ImageView imageView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); spinner=(Spinner)findViewById(R.id.spinner1); imageView=(ImageView)findViewById(R.id.imageView1); ArrayAdapter adapter= ArrayAdapter.createFromResource(this,R.array.twin, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new Lisetener()); } class Lisetener implements OnItemSelectedListener{ @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(TwinAnimaionActivity.this, position+"번째", 0).show(); //이동애니메이션 x시작점 x끝점 y시작점 y끝점 //왼쪽 위(0,0) 오른쪽 아래 (320,460) TranslateAnimation ani0 = new TranslateAnimation(0, 320, 50, 50); ani0.setDuration(2000); imageView.startAnimation(ani0); spinner.startAnimation(ani0); } @Override public void onNothingSelected(AdapterView<?> arg0) { } } }
'Android > 2012.04월 강좌' 카테고리의 다른 글
7일차 TranslateAnimation (0) | 2012.05.04 |
---|---|
7일차 복습 (0) | 2012.05.04 |
6일차 FrameAnimation 2(xml로 만드 애니메이션 이미지뷰 셋팅) (0) | 2012.05.03 |
6일차 FrameAnimation (2) | 2012.05.03 |
6일차 Dialog (0) | 2012.05.03 |