<activity android:name=".Main" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.blogjava.mobile" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/date" android:label="@string/app_name"> <activity android:name=".Main" android:label="@string/app_name" android:theme="@android:style/Theme.Dialog"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="3" /> </manifest> <?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="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="这是一个悬浮对话框" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" /> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:layout_marginTop="20dp"> <Button android:id="@+id/btnCurrentDate" android:layout_width="100dp" android:layout_height="wrap_content" android:text="当前日期" /> <Button android:id="@+id/btnFinish" android:layout_width="80dp" android:layout_height="wrap_content" android:text="关闭" /> </LinearLayout> </LinearLayout>
public void onClick(View view)
{
switch (view.getId())
{
case R.id.btnCurrentDate:
// 显示当前日期对话框
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
"yyyy-MM-dd");
dateDialog.setIcon(R.drawable.date);
dateDialog.setTitle("当前日期:"
+ simpleDateFormat.format(new Date()));
dateDialog.setButton("确定", new OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
}
});
dateDialog.setOnDismissListener(new OnDismissListener()
{
@Override
public void onDismiss(DialogInterface dialog)
{
new DateDialog.Builder(Main.this).setMessage(
"您已经关闭的当前对话框.").create().show();
}
});
dateDialog.show();
break;
case R.id.btnFinish:
// 关闭悬浮Activity
finish();
break;
}
}
@Override
public boolean onTouchEvent(MotionEvent event)
{
finish();
return true;
}
package net.blogjava.mobile;
import android.app.AlertDialog;
import android.content.Context;
import android.view.MotionEvent;
public class DateDialog extends AlertDialog
{
public DateDialog(Context context)
{
super(context);
}
@Override
public boolean onTouchEvent(MotionEvent event)
{
// 关闭显示日期对话框
dismiss();
return super.onTouchEvent(event);
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有