Android 弹出二选一窗口的实现 及Serializable

public void save() {
		@SuppressWarnings("rawtypes")
		File file = new File(SYSSETPATH);
		if (file.exists())
			file.delete();

		try {
			ObjectOutputStream objOutPutStream = new ObjectOutputStream(
					new FileOutputStream(file));
			objOutPutStream.writeObject(mSystemSet);
			objOutPutStream.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	protected void onExit() {
		new AlertDialog.Builder(this).setTitle(getString(R.string.dlg_title))
				.setMessage(getString("确定要退出吗?"))
				.setPositiveButton(getString(R.string.yes),
						new DialogInterface.OnClickListener() {
							@Override
							public void onClick(DialogInterface dialog,
									int which) {
								setResult(Msg.SYSTEMEXIT);
								finish();
							}
						}).setNegativeButton(getString(R.string.no), null)
				.show();
	}

在软件使用过程中经常会遇到点击某个按钮后弹出让我们选择 是  或者 否 的窗口,这个再android上成为dialog 今天写下二选一dialog的实现实例


setmessage是dialog的标题,setpostivebutton就是二选一的其中一个按钮,这里定义为“是”,相对应的另外一个就是否了,后面重写的onclick为选择相应的按钮后处理事件的响应, 很简单,但是要常常积累啊,初学android么,就是一步一步的积累的。



另外今天在接触 写入操作 ObjectOutputStream中的writeobject 时  必须写入的对象是序列化后的,不然会报异常,即在定义对象时 implements Serializable 借口并定义

private static final long serialVersionUID = -870520749171665437L;或者private static final long serialVersionUID = 1;




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值