main.xml布局文件:?
- <?xml?version="1.0"?encoding="utf-8"?>??
- <LinearLayout?xmlns:android="http://schemas.android.com/apk/res/android"??
- ????android:orientation="vertical"?android:layout_width="fill_parent"??
- ????android:layout_height="wrap_content"?android:id="@+id/contactItems"??
- ????android:paddingBottom="5dip"?android:paddingLeft="12dip"??
- ????android:paddingTop="5dip"?android:paddingRight="12dip">??
- ????<Spinner?android:layout_height="wrap_content"??
- ????????android:layout_width="fill_parent"?android:id="@+id/sprAnim"></Spinner>??
- ????<Button?android:layout_height="wrap_content"??
- ????????android:layout_width="fill_parent"?android:id="@+id/btn_next"??
- ????????android:text="@string/next"></Button>??
- </LinearLayout>??
next.xml布局文件:?
- <?xml?version="1.0"?encoding="utf-8"?>??
- <LinearLayout?xmlns:android="http://schemas.android.com/apk/res/android"??
- ????android:orientation="vertical"?android:layout_width="fill_parent"??
- ????android:layout_height="wrap_content"?android:id="@+id/contactItems"??
- ????android:paddingBottom="5dip"?android:paddingLeft="12dip"??
- ????android:paddingTop="5dip"?android:paddingRight="12dip">??
- ????<TextView?android:layout_height="wrap_content"??
- ????????android:layout_width="fill_parent"?android:id="@+id/text2"??
- ????????android:textSize="20dip"?android:paddingTop="12px"?android:text="@string/text2"??
- ????????android:layout_marginLeft="70px">??
- ????</TextView>??
- ????<EditText?android:layout_height="wrap_content"??
- ????????android:layout_width="fill_parent"></EditText>??
- </LinearLayout>??
strings.xml:?
- <?xml?version="1.0"?encoding="utf-8"?>??
- <resources>??
- ????<string?name="app_name">丸子联系人</string>??
- ????<string?name="contact_title">丸子联系人</string>??
- ??????
- ????<string?name="text1">IAIAI?测试</string>??
- ????<string?name="text2">测试跳转效果</string>??
- ????<string?name="next">下一页</string>??
- </resources>??
arrays.xml:?
- <?xml?version="1.0"?encoding="utf-8"?>??
- <resources>??
- ????<string-array?name="anim_type">??
- ????????<item>淡入淡出效果</item>??
- ????????<item>放大淡出效果</item>??
- ????????<item>转动淡出效果1</item>??
- ????????<item>转动淡出效果2</item>??
- ????????<item>左上角展开淡出效果</item>??
- ????????<item>压缩变小淡出效果</item>??
- ????????<item>右往左推出效果</item>??
- ????????<item>下往上推出效果</item>??
- ????????<item>左右交叉效果</item>??
- ????????<item>放大淡出效果</item>??
- ????????<item>缩小效果</item>??
- ????????<item>上下交错效果</item>??
- ????</string-array>??
- </resources>??
anim文件夹里的文件就不一一列出来了,你可以从附件里下载整个工程查看里面效果文件。?
下面是两个类文件,?
IaiaiActivity.java类:?
- package?com.iaiai.activity;??
- ??
- import?java.util.ArrayList;??
- import?java.util.List;??
- ??
- import?android.app.Activity;??
- import?android.content.Intent;??
- import?android.os.Bundle;??
- import?android.view.View;??
- import?android.view.View.OnClickListener;??
- import?android.widget.ArrayAdapter;??
- import?android.widget.Button;??
- import?android.widget.Spinner;??
- ??
- /**?
- ?*??
- ?*?<p>?
- ?*?Title:?IaiaiActivity.java?
- ?*?</p>?
- ?*?<p>?
- ?*?</p>?
- ?*?<p>?
- ?*?</p>?
- ?*?<p>?
- ?*?Http:?iaiai.iteye.com?
- ?*?</p>?
- ?*?<p>
- ?*?</p>?
- ?*/??
- public?class?IaiaiActivity?extends?Activity?{??
- ??
- ????@Override??
- ????protected?void?onCreate(Bundle?savedInstanceState)?{??
- ????????super.onCreate(savedInstanceState);??
- ????????setContentView(R.layout.main);??
- ??
- ????????final?Spinner?sprAnim?=?(Spinner)?findViewById(R.id.sprAnim);??
- ????????//?获取相应对象??
- ????????String[]?ls?=?getResources().getStringArray(R.array.anim_type);??
- ????????List<String>?list?=?new?ArrayList<String>();??
- ????????//?获取XML中定义的数组??
- ????????for?(int?i?=?0;?i?<?ls.length;?i++)?{??
- ????????????list.add(ls[i]);??
- ????????}??
- ????????ArrayAdapter<String>?animType?=?new?ArrayAdapter<String>(this,??
- ????????????????android.R.layout.simple_spinner_item,?list);??
- ????????animType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);??
- ????????sprAnim.setAdapter(animType);??
- ????????sprAnim.setSelection(0);??
- ??
- ????????Button?btn?=?(Button)?findViewById(R.id.btn_next);??
- ????????btn.setOnClickListener(new?OnClickListener()?{??
- ????????????@Override??
- ????????????public?void?onClick(View?v)?{??
- ????????????????Intent?it?=?new?Intent(IaiaiActivity.this,?NextActivity.class);??
- ????????????????startActivityForResult(it,?0);??
- ??
- ????????????????switch?(sprAnim.getSelectedItemPosition())?{??
- ????????????????case?0:??
- ????????????????????overridePendingTransition(R.anim.fade,?R.anim.hold);??
- ????????????????????break;??
- ????????????????case?1:??
- ????????????????????overridePendingTransition(R.anim.my_scale_action,??
- ????????????????????????????R.anim.my_alpha_action);??
- ????????????????????break;??
- ????????????????case?2:??
- ????????????????????overridePendingTransition(R.anim.scale_rotate,??
- ????????????????????????????R.anim.my_alpha_action);??
- ????????????????????break;??
- ????????????????case?3:??
- ????????????????????overridePendingTransition(R.anim.scale_translate_rotate,??
- ????????????????????????????R.anim.my_alpha_action);??
- ????????????????????break;??
- ????????????????case?4:??
- ????????????????????overridePendingTransition(R.anim.scale_translate,??
- ????????????????????????????R.anim.my_alpha_action);??
- ????????????????????break;??
- ????????????????case?5:??
- ????????????????????overridePendingTransition(R.anim.hyperspace_in,??
- ????????????????????????????R.anim.hyperspace_out);??
- ????????????????????break;??
- ????????????????case?6:??
- ????????????????????overridePendingTransition(R.anim.push_left_in,??
- ????????????????????????????R.anim.push_left_out);??
- ????????????????????break;??
- ????????????????case?7:??
- ????????????????????overridePendingTransition(R.anim.push_up_in,??
- ????????????????????????????R.anim.push_up_out);??
- ????????????????????break;??
- ????????????????case?8:??
- ????????????????????overridePendingTransition(R.anim.slide_left,??
- ????????????????????????????R.anim.slide_right);??
- ????????????????????break;??
- ????????????????case?9:??
- ????????????????????overridePendingTransition(R.anim.wave_scale,??
- ????????????????????????????R.anim.my_alpha_action);??
- ????????????????????break;??
- ????????????????case?10:??
- ????????????????????overridePendingTransition(R.anim.zoom_enter,??
- ????????????????????????????R.anim.zoom_exit);??
- ????????????????????break;??
- ????????????????case?11:??
- ????????????????????overridePendingTransition(R.anim.slide_up_in,??
- ????????????????????????????R.anim.slide_down_out);??
- ????????????????????break;??
- ????????????????}??
- ????????????}??
- ????????});??
- ????}??
- }??
NextActivity.java类:?
- package?com.iaiai.activity;??
- ??
- import?android.app.Activity;??
- import?android.content.Intent;??
- import?android.os.Bundle;??
- import?android.view.KeyEvent;??
- ??
- /**?
- ?*??
- ?*?<p>?
- ?*?Title:?NextActivity.java?
- ?*?</p>??
- [email protected]?
- ?*/??
- public?class?NextActivity?extends?Activity?{??
- ??
- ????@Override??
- ????protected?void?onCreate(Bundle?savedInstanceState)?{??
- ????????super.onCreate(savedInstanceState);??
- ????????setContentView(R.layout.next);??
- ????}??
- ??
- ????public?boolean?onKeyDown(int?keyCode,?KeyEvent?event)?{??
- ????????if?(keyCode?==?KeyEvent.KEYCODE_BACK?&&?event.getRepeatCount()?==?0)?{??
- ????????????Intent?intent?=?new?Intent(NextActivity.this,?IaiaiActivity.class);??
- ????????????setResult(RESULT_OK,?intent);??
- ????????????finish();??
- ????????????overridePendingTransition(R.anim.slide_up_in,?R.anim.slide_down_out);??
- ????????????return?false;??
- ????????}??
- ????????return?false;??
- ????}??
- ??
- }??
运行效果图:?
?
?