Android学习之Activity弹窗
WindowDemo.java:
package org.lee.android; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageButton; public class WindowDemo extends Activity{ private ImageButton mybut; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.setContentView(R.layout.window_demo); // 默认布局管理器 this.mybut = (ImageButton) super.findViewById(R.id.right_btn); // 取得按钮 this.mybut.setOnClickListener(new OnClickListenerImpl()); // 设置事件类 } private class OnClickListenerImpl implements OnClickListener { @Override public void onClick(View view) { Intent intent = new Intent (WindowDemo.this,MainTopRightDialog.class); startActivity(intent); } } }
MainTopRightDialog.java:
package org.lee.android; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.LinearLayout; import android.widget.Toast; public class MainTopRightDialog extends Activity { //private MyDialog dialog; private LinearLayout layout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_top_right_dialog); //dialog=new MyDialog(this); layout=(LinearLayout)findViewById(R.id.main_dialog_layout); layout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), "提示:点击窗口外部关闭窗口!", Toast.LENGTH_SHORT).show(); } }); } @Override public boolean onTouchEvent(MotionEvent event){ finish(); return true; } /* public void exitbutton1(View v) { this.finish(); } public void exitbutton0(View v) { this.finish(); MainWeixin.instance.finish();//关闭Main 这个Activity } */ }
styles.xml:
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="AnimTop2" parent="@android:style/Animation"> <item name="android:windowEnterAnimation">@anim/push_top_in2</item> <item name="android:windowExitAnimation">@anim/push_top_out2</item> </style> <style name="MyDialogStyleTop" parent="android:Theme.Dialog"> <item name="android:windowAnimationStyle">@style/AnimTop2</item> <item name="android:windowFrame">@null</item> <!-- 边框 --> <item name="android:windowIsFloating">true</item> <!-- 是否浮现在activity之上 --> <item name="android:windowIsTranslucent">true</item> <!-- 半透明 --> <item name="android:windowNoTitle">true</item> <!-- 无标题 --> <item name="android:windowBackground">@android:color/transparent</item> <!-- 背景透明 --> <item name="android:backgroundDimEnabled">false</item> <!-- 模糊 --> </style> </resources>
push_top_in2.xml:
<?xml version="1.0" encoding="utf-8"?> <!-- 上下滑入式 --> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:fromXScale="1.0" android:toXScale="1.0" android:fromYScale="0" android:toYScale="1.0" android:pivotX="0" android:pivotY="10%" android:duration="200" />
push_top_out2.xml:
<?xml version="1.0" encoding="utf-8"?> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:fromXScale="1.0" android:toXScale="1.0" android:fromYScale="1.0" android:toYScale="0" android:pivotX="0" android:pivotY="10%" android:duration="200" />
<!-- MainTopRightDialog测试 --> <activity android:name=".MainTopRightDialog" android:theme="@style/MyDialogStyleTop" android:screenOrientation="sensor" android:configChanges="orientation|keyboardHidden" > <intent-filter> <action android:name="android.intent.action.maintoprightdialog" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
相关推荐
huha 2020-10-16
xfcyhades 2020-11-20
sgafdsg 2020-11-04
Michael 2020-11-03
fengyeezju 2020-10-14
ziyexiaoxiao 2020-10-14
业余架构师 2020-10-09
OuNuo0 2020-09-29
moses 2020-09-22
Angelia 2020-09-11
qinxu 2020-09-10
刘炳昭 2020-09-10
Nostalgiachild 2020-09-07
Nostalgiachild 2020-08-17
leavesC 2020-08-14
一青年 2020-08-13
AndroidAiStudy 2020-08-07
ydc0 2020-07-30
绿豆饼 2020-07-28