alert.setTitle("提示"); alert.setMessage(msg.obj == null ? "购买请求处理失败!" : msg.obj.toString()); alert.setButton(DialogInterface.BUTTON_POSITIVE, "确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //finish掉购物车窗口 finish(); } }); alert.show();
时间: 2023-06-19 11:09:23 浏览: 38
这段代码是一个 Android 应用程序中的对话框代码。它创建了一个提示对话框,显示一个消息,如果消息为 null,则显示默认消息“购买请求处理失败!”。该对话框有一个“确定”按钮,点击“确定”按钮会关闭对话框并结束购物车窗口。这段代码使用了 Android SDK 中的 AlertDialog 类和 DialogInterface.OnClickListener 接口来实现对话框的创建和按钮的点击事件处理。
相关问题
public void save() { String title = request.getParameter("title"); String pubren = request.getParameter("pubren"); String pubtime = request.getParameter("pubtime"); String laiyuan=request.getParameter("laiyuan"); String dcontent = request.getParameter("dcontent"); String tupian2 = request.getParameter("tupian2"); String lanmuid = request.getParameter("lanmuid"); String lanmuming = request.getParameter("lanmuming"); String tuijian=request.getParameter("tuijian"); String hot=request.getParameter("hot"); String zuixin=request.getParameter("zuixin"); String zhaiyao=request.getParameter("zhaiyao"); String style=request.getParameter("style"); SimpleDateFormat sdfxinxi = new SimpleDateFormat("yyyy-MM-dd"); Xinxi xinxi = new Xinxi(); xinxi.setTitle(title == null ? "" : title); xinxi.setPubren(pubren == null ? "" : pubren); xinxi.setPubtime(new Date()); xinxi.setHot(hot!=null?1:0); xinxi.setTuijian(tuijian!=null?1:0); xinxi.setZuixin(zuixin!=null?1:0); xinxi.setClickcount(0); xinxi.setZhaiyao(zhaiyao==null?"":zhaiyao); xinxi.setDcontent(dcontent == null ? "" : dcontent); xinxi.setTupian2(tupian2 == null ? "" : tupian2); xinxi.setAgainstcount(0); xinxi.setAgreecount(0); xinxi.setLanmuid(new Integer(lanmuid)); xinxi.setLanmuming(lanmuming == null ? "" : lanmuming); DALBase.save(xinxi); try { if(style!=null&&style.equals("admin")) response.sendRedirect("xinximanager.do?actiontype=get&seedid=201&lanmuid="+xinxi.getLanmuid()); if(style!=null&&style.equals("huiyuan")) response.sendRedirect("../e/myxinximanager.jsp?seedid=m2"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /****************************************************** *********************** 内部附件支持********************* ***public void attachements(HttpServletRequest request, HttpServletResponse response, String belongid) { DALBase.delete("attachement", MessageFormat.format( " where belongid=''{0}'' and belongtable=''xinxi'' ", belongid)); String[] photos = request.getParameterValues("fileuploaded"); if (photos == null) return; for (int i = 0; i < photos.length; i++) { Attachement a = new Attachement(); a.setType("images"); a.setPubtime(new Date()); a.setBelongfileldname("id"); a.setFilename(photos[i]); a.setBelongid(belongid); a.setBelongtable("xinxi"); a.setUrl(SystemParam.getSiteRoot() + "/upload/temp/" + a.getFilename()); a.setTitle(a.getFilename()); DALBase.save(a); } }解释每一行代码
这是一段Java代码,根据传入的HTTP请求参数保存一个信息(Xinxi)到数据库中。下面是每行代码的解释:
```java
public void save() { // 定义一个公有方法save()
// 从请求参数中获取信息标题、发布者、发布时间、来源、正文内容、图片、栏目ID、栏目名称、推荐、热点和最新等信息
String title = request.getParameter("title");
String pubren = request.getParameter("pubren");
String pubtime = request.getParameter("pubtime");
String laiyuan=request.getParameter("laiyuan");
String dcontent = request.getParameter("dcontent");
String tupian2 = request.getParameter("tupian2");
String lanmuid = request.getParameter("lanmuid");
String lanmuming = request.getParameter("lanmuming");
String tuijian=request.getParameter("tuijian");
String hot=request.getParameter("hot");
String zuixin=request.getParameter("zuixin");
String zhaiyao=request.getParameter("zhaiyao");
String style=request.getParameter("style");
// 定义一个日期格式化对象,格式为"yyyy-MM-dd"
SimpleDateFormat sdfxinxi = new SimpleDateFormat("yyyy-MM-dd");
// 创建一个信息对象
Xinxi xinxi = new Xinxi();
// 将获取到的信息设置到信息对象中
xinxi.setTitle(title == null ? "" : title);
xinxi.setPubren(pubren == null ? "" : pubren);
xinxi.setPubtime(new Date()); // 设置发布时间为当前时间
xinxi.setHot(hot!=null?1:0); // 如果参数hot不为空,则将热点属性设为1,否则设为0
xinxi.setTuijian(tuijian!=null?1:0); // 如果参数tuijian不为空,则将推荐属性设为1,否则设为0
xinxi.setZuixin(zuixin!=null?1:0); // 如果参数zuixin不为空,则将最新属性设为1,否则设为0
xinxi.setClickcount(0); // 设置点击次数为0
xinxi.setZhaiyao(zhaiyao==null?"":zhaiyao);
xinxi.setDcontent(dcontent == null ? "" : dcontent);
xinxi.setTupian2(tupian2 == null ? "" : tupian2);
xinxi.setAgainstcount(0); // 设置反对次数为0
xinxi.setAgreecount(0); // 设置赞同次数为0
xinxi.setLanmuid(new Integer(lanmuid)); // 将栏目ID设置到信息对象中
xinxi.setLanmuming(lanmuming == null ? "" : lanmuming);
// 调用数据访问层的save()方法保存信息对象到数据库中
DALBase.save(xinxi);
try {
// 根据请求参数中的style值进行不同的重定向操作
if(style!=null&&style.equals("admin"))
response.sendRedirect("xinximanager.do?actiontype=get&seedid=201&lanmuid="+xinxi.getLanmuid());
if(style!=null&&style.equals("huiyuan"))
response.sendRedirect("../e/myxinximanager.jsp?seedid=m2");
} catch (IOException e) {
e.printStackTrace();
}
}
// 定义一个公有方法attachements()用于支持内部附件
public void attachements(HttpServletRequest request, HttpServletResponse response, String belongid) {
// 删除已存在的附件
DALBase.delete("attachement", MessageFormat.format(" where belongid=''{0}'' and belongtable=''xinxi'' ", belongid));
// 获取请求参数中的上传的图片文件名
String[] photos = request.getParameterValues("fileuploaded");
if (photos == null)
return;
// 遍历图片文件名数组,创建附件对象并保存到数据库中
for (int i = 0; i < photos.length; i++) {
Attachement a = new Attachement();
a.setType("images");
a.setPubtime(new Date()); // 设置附件发布时间为当前时间
a.setBelongfileldname("id");
a.setFilename(photos[i]);
a.setBelongid(belongid);
a.setBelongtable("xinxi");
a.setUrl(SystemParam.getSiteRoot() + "/upload/temp/" + a.getFilename());
a.setTitle(a.getFilename());
DALBase.save(a);
}
}
```
import defaultSettings from '@/settings' const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dynamicTitle } = defaultSettings const storageSetting = {} const state = { title: '', theme: storageSetting.theme || '#409EFF', sideTheme: storageSetting.sideTheme || sideTheme, showSettings: showSettings, topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav, tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView, fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader, sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo, dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle } const mutations = { CHANGE_SETTING: (state, { key, value }) => { if (state.hasOwnProperty(key)) { state[key] = value } } } const actions = { // 修改布局设置 changeSetting({ commit }, data) { commit('CHANGE_SETTING', data) }, // 设置网页标题 setTitle({ commit }, title) { state.title = title } } export default { namespaced: true, state, mutations, actions }怎样在const storageSetting = {}通过调用api赋值
在这段代码中,const storageSetting = {} 是一个空对象,需要通过调用api来给它赋值。你可以使用浏览器提供的本地存储API(如localStorage或sessionStorage)来将用户的设置保存在浏览器中,并在用户下次访问时恢复这些设置。
例如,你可以使用localStorage.setItem()方法将用户的主题设置存储在localStorage中:
```
localStorage.setItem('theme', '#409EFF');
```
然后,在初始化store时,你可以使用localStorage.getItem()方法来获取已存储的设置并将其赋值给storageSetting对象:
```
const storageSetting = {
theme: localStorage.getItem('theme')
};
```
这样,用户的设置就会在store中得到恢复。注意,localStorage只能存储字符串类型的数据,如果你需要存储其他类型的数据,需要使用JSON.stringify()和JSON.parse()方法进行转换。