• 关于

    @param

    的搜索结果

回答

一、在ArticleDao中添加分页查询的方法: /** * 分页查询 * @param hql 查询的条件 * @param offset 开始记录 * @param length 一次查询几条记录 * @return */ public List queryForPage(final String hql,final int offset,final int length); /** *//** * 查询所有记录数 * @param hql 查询的条件 * @return 总记录数 */ public int getAllRowCount(String hql); 二、在ArticleDaoImpl中给出相应方法的具体实现: /** 查询所有记录数 * @return 总记录数 */ public int getAllRowCount(String hql) { return getHibernateTemplate().find(hql).size(); } /** 分页查询 * @param hql 查询的条件 @param offset 开始记录 @param length 一次查询几条记录 @return */ public List queryForPage(final String hql, final int offset, final int length) { List list = getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query query = session.createQuery(hql); query.setFirstResult(offset); query.setMaxResults(length); List list = query.list(); return list; } }); return list; } 三、在ArticleService中添加方法分页查询的方法: /** * 分页查询 * @param currentPage 当前第几页 * @param pageSize 每页大小 * @return 封闭了分页信息(包括记录集list)的Bean */ public PageBean queryForPage(int pageSize,int currentPage); 四、在ArticleServiceImpl中给出相应方法的具体实现: /** 分页查询 @param currentPage 当前第几页 @param pageSize 每页大小 @return 封闭了分页信息(包括记录集list)的Bean */ public PageBean queryForPage(int pageSize,int page){ final String hql = "from Article"; int allRow = articleDao.getAllRowCount(hql); int totalPage = PageBean.countTotalPage(pageSize, allRow); final int offset = PageBean.countOffset(pageSize, page); final int length = pageSize; final int currentPage = PageBean.countCurrentPage(page); List list = articleDao.queryForPage(hql,offset, length); //"一页"的记录 //把分页信息保存到Bean中 PageBean pageBean = new PageBean(); pageBean.setPageSize(pageSize); pageBean.setCurrentPage(currentPage); pageBean.setAllRow(allRow); pageBean.setTotalPage(totalPage); pageBean.setList(list); pageBean.init(); return pageBean; } 最后一步,根据需要,在分页页面上的相应位置进行配置。基本配置如下: 首页 上一页 /s:if 首页 [url=...?page=上一页[/url] … /s:else … ">下一页 ">尾页 一、在ArticleDao中添加分页查询的方法: /** * 分页查询 * @param hql 查询的条件 * @param offset 开始记录 * @param length 一次查询几条记录 * @return */ public List queryForPage(final String hql,final int offset,final int length); /** *//** * 查询所有记录数 * @param hql 查询的条件 * @return 总记录数 */ public int getAllRowCount(String hql); 二、在ArticleDaoImpl中给出相应方法的具体实现: /** 查询所有记录数 * @return 总记录数 */ public int getAllRowCount(String hql) { return getHibernateTemplate().find(hql).size(); } /** 分页查询 * @param hql 查询的条件 @param offset 开始记录 @param length 一次查询几条记录 @return */ public List queryForPage(final String hql, final int offset, final int length) { List list = getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query query = session.createQuery(hql); query.setFirstResult(offset); query.setMaxResults(length); List list = query.list(); return list; } }); return list; } 三、在ArticleService中添加方法分页查询的方法: /** * 分页查询 * @param currentPage 当前第几页 * @param pageSize 每页大小 * @return 封闭了分页信息(包括记录集list)的Bean */ public PageBean queryForPage(int pageSize,int currentPage); 四、在ArticleServiceImpl中给出相应方法的具体实现: /** 分页查询 @param currentPage 当前第几页 @param pageSize 每页大小 @return 封闭了分页信息(包括记录集list)的Bean */ public PageBean queryForPage(int pageSize,int page){ final String hql = "from Article"; int allRow = articleDao.getAllRowCount(hql); int totalPage = PageBean.countTotalPage(pageSize, allRow); final int offset = PageBean.countOffset(pageSize, page); final int length = pageSize; final int currentPage = PageBean.countCurrentPage(page); List list = articleDao.queryForPage(hql,offset, length); //"一页"的记录 //把分页信息保存到Bean中 PageBean pageBean = new PageBean(); pageBean.setPageSize(pageSize); pageBean.setCurrentPage(currentPage); pageBean.setAllRow(allRow); pageBean.setTotalPage(totalPage); pageBean.setList(list); pageBean.init(); return pageBean; } 最后一步,根据需要,在分页页面上的相应位置进行配置。基本配置如下: 首页 上一页 /s:if 首页 [url=...?page=上一页[/url] … /s:else … ">下一页 ">尾页 /s:if 下一页 尾页 /s:else 共 value="pageBean.allRow" />条记录, value="pageBean.totalPage" />页 至此,网站的分页功能就完成了。 /s:if 下一页 尾页 /s:else 共 value="pageBean.allRow" />条记录, value="pageBean.totalPage" />页 至此,网站的分页功能就完成了。
小旋风柴进 2019-12-02 01:56:20 0 浏览量 回答数 0

问题

java aes加密解密如何用php实现

下面java的aes加密解密如何用php实现 package cn.hnqst.commons.util; import java.math.BigInteger;import java.security.MessageDigest;imp...
泡儿 2019-12-01 19:55:36 2624 浏览量 回答数 1

回答

参考import java.io.File; import java.io.IOException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.ss.util.CellRangeAddress; import org.junit.Test; /** * * @author wcyong * * @date 2013-6-21 */ public class TestReadMergeRegionExcel { @Test public void testReadExcel() { readExcelToObj(“f:\\test\\out3.xls”); } /** * 读取excel数据 * @param path */ private void readExcelToObj(String path) { Workbook wb = null; try { wb = WorkbookFactory.create(new File(path)); readExcel(wb, 0, 0, 0); } catch (InvalidFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } /** * 读取excel文件 * @param wb * @param sheetIndex sheet页下标:从0开始 * @param startReadLine 开始读取的行:从0开始 * @param tailLine 去除最后读取的行 */ private void readExcel(Workbook wb,int sheetIndex, int startReadLine, int tailLine) { Sheet sheet = wb.getSheetAt(sheetIndex); Row row = null; for(int i=startReadLine; i<sheet.getLastRowNum()-tailLine+1; i++) { row = sheet.getRow(i); for(Cell c : row) { boolean isMerge = isMergedRegion(sheet, i, c.getColumnIndex()); //判断是否具有合并单元格 if(isMerge) { String rs = getMergedRegionValue(sheet, row.getRowNum(), c.getColumnIndex()); System.out.print(rs + “ “); }else { System.out.print(c.getRichStringCellValue()+” “); } } System.out.println(); } } /** * 获取合并单元格的值 * @param sheet * @param row * @param column * @return */ public String getMergedRegionValue(Sheet sheet ,int row , int column){ int sheetMergeCount = sheet.getNumMergedRegions(); for(int i = 0 ; i < sheetMergeCount ; i++){ CellRangeAddress ca = sheet.getMergedRegion(i); int firstColumn = ca.getFirstColumn(); int lastColumn = ca.getLastColumn(); int firstRow = ca.getFirstRow(); int lastRow = ca.getLastRow(); if(row >= firstRow && row <= lastRow){ if(column >= firstColumn && column <= lastColumn){ Row fRow = sheet.getRow(firstRow); Cell fCell = fRow.getCell(firstColumn); return getCellValue(fCell) ; } } } return null ; } /** * 判断合并了行 * @param sheet * @param row * @param column * @return */ private boolean isMergedRow(Sheet sheet,int row ,int column) { int sheetMergeCount = sheet.getNumMergedRegions(); for (int i = 0; i < sheetMergeCount; i++) { CellRangeAddress range = sheet.getMergedRegion(i); int firstColumn = range.getFirstColumn(); int lastColumn = range.getLastColumn(); int firstRow = range.getFirstRow(); int lastRow = range.getLastRow(); if(row == firstRow && row == lastRow){ if(column >= firstColumn && column <= lastColumn){ return true; } } } return false; } /** * 判断指定的单元格是否是合并单元格 * @param sheet * @param row 行下标 * @param column 列下标 * @return */ private boolean isMergedRegion(Sheet sheet,int row ,int column) { int sheetMergeCount = sheet.getNumMergedRegions(); for (int i = 0; i < sheetMergeCount; i++) { CellRangeAddress range = sheet.getMergedRegion(i); int firstColumn = range.getFirstColumn(); int lastColumn = range.getLastColumn(); int firstRow = range.getFirstRow(); int lastRow = range.getLastRow(); if(row >= firstRow && row <= lastRow){ if(column >= firstColumn && column <= lastColumn){ return true; } } } return false; } /** * 判断sheet页中是否含有合并单元格 * @param sheet * @return */ private boolean hasMerged(Sheet sheet) { return sheet.getNumMergedRegions() > 0 ? true : false; } /** * 合并单元格 * @param sheet * @param firstRow 开始行 * @param lastRow 结束行 * @param firstCol 开始列 * @param lastCol 结束列 */ private void mergeRegion(Sheet sheet, int firstRow, int lastRow, int firstCol, int lastCol) { sheet.addMergedRegion(new CellRangeAddress(firstRow, lastRow, firstCol, lastCol)); } /** * 获取单元格的值 * @param cell * @return */ public String getCellValue(Cell cell){ if(cell == null) return “”; if(cell.getCellType() == Cell.CELL_TYPE_STRING){ return cell.getStringCellValue(); }else if(cell.getCellType() == Cell.CELL_TYPE_BOOLEAN){ return String.valueOf(cell.getBooleanCellValue()); }else if(cell.getCellType() == Cell.CELL_TYPE_FORMULA){ return cell.getCellFormula() ; }else if(cell.getCellType() == Cell.CELL_TYPE_NUMERIC){ return String.valueOf(cell.getNumericCellValue()); } return “”; } }
小旋风柴进 2019-12-02 02:02:36 0 浏览量 回答数 0

回答

用这个:存放用键值对形式:HealthMap.put("key", 要传递的值);,用的时候直接用HealthMap.get("key");就可以了public class HealthMap { private static Map map = new ConcurrentHashMap(); /** * 传值 * @param key * @param obj */ public static void put(String key, Object obj) { map.put(key, obj); } /** * 取值 默认删除内存引用 * @param key * @return */ public static Object get(String key) { return map.remove(key); } /** * 取值 自定义是否删除内存引用 * @param key * @param isDelete * @return */ public static Object get(String key, boolean isDelete) { if (isDelete) { return get(key); } else { return map.get(key); } } }
爵霸 2019-12-02 02:10:46 0 浏览量 回答数 0

问题

有关于程序健壮性的问题

从服务器获取到的数据或提交到服务器的数据有可能是nil,那我们是否需要对需要用到的每个数据都判断其是否为nil呢? 如果是的话,会不会有些繁琐? 尤其是当从服务器返回的数据或提交到服务器的数据比较多的时候。问一下该怎么保证 程序的健壮性同时...
爵霸 2019-12-01 20:15:01 784 浏览量 回答数 1

回答

@RestController public class ShopController { @Autowired private ShopService shopService; /** * 获取商店详情 * * @param userId * 用户id * @param shopId * 商家id * * @return 商店详情 */ @RequestMapping(value = "/getShopDeatil") public ResultObject getShopDeatil(@RequestParam("userId") String userId, @RequestParam("shopId") Integer shopId) { System.out.println("请求路径:/getShopDeatil"+"\n"+"{"+"\n"+ "loginInfo:"+userId+"\n"+ "password:"+shopId+"\n"+ "}" ); ResultObject ro = shopService.getShopDetail(userId, shopId); return ro; } }
a123456678 2019-12-02 02:14:11 0 浏览量 回答数 0

问题

IndexedDB的open问题

附上代码:IndexDB.js var datalist = [ {id:1,name:"程文1",phone:"13237177923",sex:"1",address:"宝石园",home:"驰誉"}, ...
a123456678 2019-12-01 20:17:16 846 浏览量 回答数 1

回答

/** * 系统上下文(线程级别) * @author Jeff.sui * @since 2011.4.24 * */ public class AOLContext { private ThreadLocal<Map<String,Object>> additionalContextHolder = new ThreadLocal<Map<String,Object>>(); private static AOLContext inst = null; public AOLContext(){ } public static AOLContext getContext(){ if (inst==null) { inst = new AOLContext(); } return inst; } public Map<String,Object> getApplication(){ return ActionContext.getContext().getApplication(); } public Locale getLocale() { return ActionContext.getContext().getLocale(); } public Map<String, Object> getParameters() { return ActionContext.getContext().getParameters(); } public HttpServletRequest getRequest() { return ServletActionContext.getRequest(); } public HttpServletResponse getResponse() { return ServletActionContext.getResponse(); } public ServletContext getServletContext() { return ServletActionContext.getServletContext(); } /** * 从HttpRequest中获得指定参数,并以Integer形式返回。 * @param paramName 参数名 * @return 参数值 */ public Integer getReqParaAsInt(String paramName) { String pv = ServletActionContext.getRequest().getParameter(paramName); if(pv!=null) { return Integer.valueOf(pv); } return null; } /** * 从HttpRequest中获得指定参数,并以Short形式返回。 * @param paramName 参数名 * @return 参数值 */ public Short getReqParaAsShort(String paramName) { String pv = ServletActionContext.getRequest().getParameter(paramName); if(pv!=null) { return Short.valueOf(pv); } return null; } /** * 从HttpRequest中获得指定参数,并以字符串形式返回。 * @param paramName 参数名 * @return 参数值 */ public String getReqParaAsStr(String paramName) { return ServletActionContext.getRequest().getParameter(paramName); } /** * 向系统上下文中添加一个对象 * @param key 对象KEY * @param value 对象实例 */ public void put(String key, Object value) { additionalContextHolder.get().put(key, value); } /** * 从系统上下文中获得指定Key的对象 * @param key KEY * @return KEY对应的对象 */ public Object get(String key) { return additionalContextHolder.get().get(key); } void init() { additionalContextHolder.set(new HashMap<String,Object>()); } void clear() { additionalContextHolder.set(null); } }
a123456678 2019-12-02 02:07:51 0 浏览量 回答数 0

回答

/** * 功能概要: * * @author linbingwen * @since 2015年9月5日 */ public class Test2 { /** * @author linbingwen * @since 2015年9月5日 * @param args */ public static void main(String[] args) { String input = "D:" + File.separator + "hello.jpg"; String output = "D:" + File.separator + "hello1.jpg"; writeFile(input,output); } /** * 文件复制操作,可以是图片、文字 * * @author linbingwen * @since 2015年9月5日 * @param input * @param output */ public static void writeFile(String input, String output) { FileInputStream fis = null; FileOutputStream fos = null; byte[] buffer = new byte[100]; int temp = 0; try { fis = new FileInputStream(input); fos = new FileOutputStream(output); while (true) { temp = fis.read(buffer, 0, buffer.length); if (temp == -1) { break; } fos.write(buffer, 0, temp); } } catch (Exception e) { System.out.println(e); } finally { try { fis.close(); fos.close(); } catch (Exception e2) { System.out.println(e2); } } } }
蛮大人123 2019-12-02 02:18:02 0 浏览量 回答数 0

回答

我觉得应该封装在dao层,不然怎么获取session? demo如下: public class BaseDaoImpl<E> implements BaseDao<E> { private Logger log = Logger.getLogger(this.getClass()); @PersistenceContext private EntityManager entityManager; protected Class<?> entityClass; public BaseDaoImpl(Class<E> entityClass) { this.entityClass = Reflections.getClassGenricType(getClass()); } /** * 获取实体工厂管理对象 */ public EntityManager getEntityManager() { return entityManager; } /** * 获取 Session */ public Session getSession() { return (Session) getEntityManager().getDelegate(); } /** * 使用检索标准对象分页查询 * * @param page * @param detachedCriteria * @param resultTransformer * @return */ @SuppressWarnings("unchecked") public Page<E> find(Page<E> page, DetachedCriteria detachedCriteria, ResultTransformer resultTransformer) { // get count page.setTotalCount(count(detachedCriteria)); if (page.getTotalCount() < 1) { return page; } Criteria criteria = detachedCriteria.getExecutableCriteria(getSession()); criteria.setResultTransformer(resultTransformer); // set page // 分页 if (page.getPageNo() > 0 && page.getPageSize() > 0) { criteria.setFirstResult(page.getFirst() - 1); criteria.setMaxResults(page.getPageSize()); } page.setResult(criteria.list()); return page; } /** * 使用检索标准对象查询 * * @param detachedCriteria * @param resultTransformer * @return */ @SuppressWarnings("unchecked") public List<E> find(DetachedCriteria detachedCriteria, ResultTransformer resultTransformer) { Criteria criteria = detachedCriteria.getExecutableCriteria(getSession()); criteria.setResultTransformer(resultTransformer); return criteria.list(); } /** * 创建与会话无关的检索标准对象 * * @param criterions Restrictions.eq("name", value); * @return */ public DetachedCriteria createDetachedCriteria(Criterion... criterions) { DetachedCriteria dc = DetachedCriteria.forClass(entityClass); for (Criterion c : criterions) { dc.add(c); } return dc; } /** } 所有的daoImpl都继承这个BaseDaoImpl 然后调用的时候在service层直接调用,demo如下: DetachedCriteria dc = baseDao.createDetachedCriteria(); dc.add(Restrictions.like("name", "%" + name + "%")); dc.addOrder(Order.asc("id")); //page= baseDao.find(page, dc); list = baseDao.find(dc)
a123456678 2019-12-02 02:13:36 0 浏览量 回答数 0

回答

自定义对话框不是这么搞啊 MyDialog.java package com.antex.assist; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import com.antex.R; /** * <h3>package:</h3> com.antex.assist <br> * <h3>file:</h3> MyDialog.java <br> * * <h3>Description:自定义dialog</h3><br> * <h3>创建时间:</h3>2013-10 * * * <pre> * @author xiaosanyu<br> * &nbsp;&nbsp;email: 446251495@qq.com<br> * &nbsp;&nbsp;blog: <a href="http://blog.csdn.net/a87b01c14">http://blog.csdn.net/a87b01c14</a> * </pre> * */ public class MyDialog extends Dialog { /** * 构造函数 * * @param context * 上下文环境 * @param theme * 主题 */ public MyDialog(Context context, int theme) { super(context, theme); } /** * 构造函数 * * @param context * 上下文环境 */ public MyDialog(Context context) { super(context); } /** * Helper class for creating a custom dialog */ public static class Builder { /** 上下文环境 */ private Context context; /** 标题 */ private String title; /** 消息内容 */ private String message; /** 左侧按钮文字 */ private String positiveButtonText; /** 右侧按钮文字 */ private String negativeButtonText; /** 中间按钮文字 */ private String neutralButtonText; /** 子视图 */ private View contentView; /** 标题图标 */ private int titleimg = 0; /** 左侧按钮点击监听 */ private DialogInterface.OnClickListener positiveButtonClickListener; /** 中间按钮点击监听 */ private DialogInterface.OnClickListener neutralButtonClickListener; /** 右侧按钮点击监听 */ private DialogInterface.OnClickListener negativeButtonClickListener; /** * 构造器 * * @param context * 上下文环境 */ public Builder(Context context) { this.context = context; } /** * Set the Dialog message from String * * @param message * String类型对话框消息 * @return Builder 是个抽象类。用于抽象创建下属dialog等类 */ public Builder setMessage(String message) { this.message = message; return this; } /** * Set the Dialog message from resource * * @param message * int型根据ID获取会话框消息 * @return Builder 是个抽象类。用于抽象创建下属dialog等类 */ public Builder setMessage(int message) { this.message = (String) context.getText(message); return this; } /** * Set the Dialog title from resource * * @param title * int型根据ID获取对话框标题 * @return Builder 是个抽象类。用于抽象创建下属dialog等类 */ public Builder setTitle(int title) { this.title = (String) context.getText(title); return this; } /** * Set the Dialog titleimg from resource * * @param titleimg * 对话框图标 * @return Builder 是个抽象类。用于抽象创建下属dialog等类 */ public Builder setIcon(int titleimg) { this.titleimg = titleimg; return this; } /** * Set the Dialog title from String * * @param title * String型对话框标题 * @return Builder 是个抽象类。用于抽象创建下属dialog等类 */ public Builder setTitle(String title) { this.title = title; return this; } /** * Set a custom content view for the Dialog. If a message is set, the * contentView is not added to the Dialog... * * @param v * 对话框子视图 * @return Builer 是个抽象类。用于抽象创建下属dialog等类 */ public Builder setContentView(View v) { this.contentView = v; return this; } /** * Set the positive button resource and it's listener * * @param positiveButtonText * 按钮文本 * @param listener * 按钮点击监听 * @return Builer 是个抽象类。用于抽象创建下属dialog等类 */ public Builder setPositiveButton(int positiveButtonText, DialogInterface.OnClickListener listener) { this.positiveButtonText = (String) context .getText(positiveButtonText); this.positiveButtonClickListener = listener; return this; } /** * Set the positive button text and it's listener * * @param positiveButtonText * 按钮文本 * @param listener * 按钮点击监听 * @return Builer 是个抽象类。用于抽象创建下属dialog等类 */ public Builder setPositiveButton(String positiveButtonText, DialogInterface.OnClickListener listener) { this.positiveButtonText = positiveButtonText; this.positiveButtonClickListener = listener; return this; } /** * Set the negative button resource and it's listener * * @param negativeButtonText * 按钮文本 * @param listener * 按钮点击监听 * @return Builer 是个抽象类。用于抽象创建下属dialog等类 */ public Builder setNegativeButton(int negativeButtonText, DialogInterface.OnClickListener listener) { this.negativeButtonText = (String) context .getText(negativeButtonText); this.negativeButtonClickListener = listener; return this; } /** * Set the negative button text and it's listener * * @param negativeButtonText * 按钮文本 * @param listener * 按钮点击监听 * @return Builer 是个抽象类。用于抽象创建下属dialog等类 */ public Builder setNegativeButton(String negativeButtonText, DialogInterface.OnClickListener listener) { this.negativeButtonText = negativeButtonText; this.negativeButtonClickListener = listener; return this; } /** * Set the Neutral button resource and it's listener * * @param neutralButtonText * 按钮文本 * @param listener * 按钮点击监听 * @return Builer 是个抽象类。用于抽象创建下属dialog等类 */ public Builder setNeutralButton(int neutralButtonText, DialogInterface.OnClickListener listener) { this.neutralButtonText = (String) context .getText(neutralButtonText); this.negativeButtonClickListener = listener; return this; } /** * Set the Neutral button text and it's listener * * @param neutralButtonText * 按钮文本 * @param listener * 按钮点击监听 * @return Builer 是个抽象类。用于抽象创建下属dialog等类 */ public Builder setNeutralButton(String neutralButtonText, DialogInterface.OnClickListener listener) { this.neutralButtonText = neutralButtonText; this.neutralButtonClickListener = listener; return this; } /** * Create the custom dialog * * @return MyDialog 返回自定义Dialog */ public MyDialog create() { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); // instantiate the dialog with the custom Theme final MyDialog dialog = new MyDialog(context, R.style.MyDialog); View layout = inflater.inflate(R.layout.dialog, new LinearLayout( context), false); ImageView titleimage = (ImageView) layout .findViewById(R.id.dialog_title_image); TextView tv = (TextView) layout.findViewById(R.id.dialog_msg); Button positiveButton = (Button) layout .findViewById(R.id.positiveButton); Button negativeButton = (Button) layout .findViewById(R.id.negativeButton); Button neutralButton = (Button) layout .findViewById(R.id.neutralButton); dialog.addContentView(layout, new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); // set the dialog title if (title != null) ((TextView) layout.findViewById(R.id.dialog_title)) .setText(title); if (titleimg != 0) titleimage.setBackgroundResource(titleimg); else titleimage.setVisibility(View.GONE); // set the confirm button if (positiveButtonText != null) { positiveButton.setText(positiveButtonText); if (positiveButtonClickListener != null) { positiveButton .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { positiveButtonClickListener.onClick(dialog, DialogInterface.BUTTON_POSITIVE); } }); } } else { // if no confirm button just set the visibility to GONE positiveButton.setVisibility(View.GONE); } // set the cancel button if (negativeButtonText != null) { negativeButton.setText(negativeButtonText); if (negativeButtonClickListener != null) { negativeButton .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { negativeButtonClickListener.onClick(dialog, DialogInterface.BUTTON_POSITIVE); } }); } } else { // if no confirm button just set the visibility to GONE negativeButton.setVisibility(View.GONE); } // set the neutral button if (neutralButtonText != null) { neutralButton.setText(neutralButtonText); LayoutParams lp = positiveButton.getLayoutParams(); lp.width = convertDIP2PX(80); positiveButton.setLayoutParams(lp); RelativeLayout.LayoutParams contentLayoutParams = new RelativeLayout.LayoutParams( convertDIP2PX(80), RelativeLayout.LayoutParams.WRAP_CONTENT); contentLayoutParams.leftMargin = convertDIP2PX(15); contentLayoutParams.addRule(RelativeLayout.RIGHT_OF, R.id.neutralButton); negativeButton.setLayoutParams(contentLayoutParams); if (neutralButtonClickListener != null) { neutralButton .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { neutralButtonClickListener.onClick(dialog, DialogInterface.BUTTON_POSITIVE); } }); } } else { // if no neutral button just set the visibility to GONE neutralButton.setVisibility(View.GONE); } // set the content message if (message != null) { tv.setText(message); } if (contentView != null) { // add the contentView to the dialog body if (message == null || message == "") tv.setVisibility(View.GONE); LinearLayout ll = (LinearLayout) layout .findViewById(R.id.content); // WindowManager manager = (WindowManager) context // .getSystemService(Context.WINDOW_SERVICE); // Display display = manager.getDefaultDisplay(); // int width = display.getWidth(); LinearLayout.LayoutParams contentLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); contentLayoutParams.weight = 0; // contentLayoutParams.gravity=Gravity.CENTER_VERTICAL; contentLayoutParams.leftMargin = 30; contentLayoutParams.rightMargin = 30; contentLayoutParams.topMargin = 10; ll.addView(contentView, contentLayoutParams); } dialog.setContentView(layout); return dialog; } /** * 转换dip为px * * @param dip * dip大小 * @return int dip单位转换成px大小 */ public int convertDIP2PX(int dip) { float scale = context.getResources().getDisplayMetrics().density; return (int) (dip * scale + 0.5f); } } } 布局文件 dialog.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/dialog_bg" android:gravity="center_horizontal" android:orientation="vertical" > <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="20dip" > <ImageView android:id="@+id/dialog_title_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="15dip" android:layout_marginTop="15dip" android:background="@drawable/dialog_title_image" android:contentDescription="@string/button_back" /> <TextView android:id="@+id/dialog_title" style="@style/DialogText.Title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="19dp" android:layout_marginTop="20dip" android:layout_toRightOf="@+id/dialog_title_image" /> </RelativeLayout> <TextView android:layout_width="wrap_content" android:layout_height="1dip" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:layout_marginTop="5dip" android:background="@drawable/lins" /> <ScrollView android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:fillViewport="true" > <LinearLayout android:id="@+id/content" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:id="@+id/dialog_msg" style="@style/DialogText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="15dip" android:layout_marginRight="5dip" android:layout_marginTop="10dip" /> </LinearLayout> </ScrollView> <RelativeLayout android:id="@+id/drl" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="bottom|center_horizontal" android:paddingBottom="30dip" android:paddingTop="10dip" > <Button android:id="@+id/positiveButton" android:layout_width="100dip" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:background="@drawable/button_selector" android:text="@string/button_ok" android:textColor="@color/black" android:textSize="20sp" android:textStyle="bold" /> <Button android:id="@+id/neutralButton" android:layout_width="80dip" android:layout_height="wrap_content" android:layout_marginLeft="15dip" android:layout_toRightOf="@id/positiveButton" android:background="@drawable/button_selector" android:textColor="@color/black" android:textSize="20sp" android:textStyle="bold" /> <Button android:id="@+id/negativeButton" android:layout_width="100dip" android:layout_height="wrap_content" android:layout_marginLeft="30dip" android:layout_toRightOf="@id/neutralButton" android:background="@drawable/button_selector" android:text="@string/button_cancel" android:textColor="@color/black" android:textSize="20sp" android:textStyle="bold" /> </RelativeLayout> </LinearLayout> style <style name="MyDialog" parent="@android:Theme.Dialog"> <item name="android:windowFrame">@null</item> <item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@drawable/dialog_bg</item> <item name="android:windowIsFloating">true</item> <item name="android:windowContentOverlay">@null</item> </style> <style name="DialogText"> <item name="android:textColor">#FF000000</item> <item name="android:textSize">20sp</item> <item name="android:textStyle">bold</item> </style> <style name="DialogText.Title"> <item name="android:textSize">25sp</item> <item name="android:textStyle">bold</item> <item name="android:textColor">#1E90FF</item> </style> 调用 MyDialog.Builder customBuilder = new MyDialog.Builder(mContext0); LayoutInflater layout =getLayoutInflater(); View longinDialogView = layout.inflate(R.layout.logindialog, null, false); //获取布局中的控件 EditText mUserName = (EditText)longinDialogView.findViewById( MResource.getIdByName(getApplication(), "id", "edit_username")); EditText mPassword = (EditText)longinDialogView.findViewById( MResource.getIdByName(getApplication(), "id", "edit_password")); customBuilder.setTitle("").setContentView(view).setPositiveButton(“确定”, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).setNegativeButton(“取消”, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); Dialog dialog = customBuilder.create(); dialog.show();
爵霸 2019-12-02 02:23:01 0 浏览量 回答数 0

回答

/** * BASE标准解码 * * @author lz * @param buff * @return */ public static String decodeBase64(String str) { return str == null ? null : StringUtils.newStringUtf8(base64.decode(str)); } /** * BASE64 编码 * * @param s * @return */ public static String encodeBufferBase64(byte[] buff) { return buff == null ? null : encoder.encodeBuffer(buff).trim(); }
爵霸 2019-12-02 02:24:20 0 浏览量 回答数 0

问题

vsftp, Java代码登录能成功,上传下载文件超时

CentOS 7.2 64建立的vsftp, Java代码登录能成功,上传下载文件超时 ,工具操作没有任何问题,求大佬解决! /** * 向FTP服务器上传文件 * * @param host FTP服务器hostname ...
giant_lizard 2019-12-01 20:05:58 1342 浏览量 回答数 2

回答

/** * 从服务端同步反馈回复 * @param title 反馈标题, 当用户没有创建过用户反馈时,需要传入这个参数用于创建用户反馈。 * @param contact 联系方式,邮箱或qq。 * @param block 结果回调 * @discussion 可以在 block 中处理反馈数据 (AVUserFeedbackThread 数组),然后将其传入自定义用户反馈界面。 */ - (void)syncFeedbackThreadsWithBlock:(NSString *)title contact:(NSString *)contact block:(AVArrayResultBlock)block; 可以通过调用这个方法实现
a123456678 2019-12-02 03:14:19 0 浏览量 回答数 0

问题

想问下这段代码是什么含义呀?

<?php/** NotORM - simple reading data from the database @link http://www.notorm.com/ @author Jakub Vrana, http://ww...
幸福量子 2019-12-01 20:03:45 1125 浏览量 回答数 0

问题

php的类里可以有两个构造函数吗?

class ecs_error { var $_message = array(); var $_template = ''; var $error_no = 0; /** * 构造函数...
小旋风柴进 2019-12-01 20:08:54 804 浏览量 回答数 1

回答

核心代码: // 得到trigger CronTriggerBean trigger = (CronTriggerBean) scheduler.getTrigger( triggerName, Scheduler.DEFAULT_GROUP); //设置表达式 trigger.setCronExpression(cronExpression); // 重置job scheduler.rescheduleJob(triggerName, Scheduler.DEFAULT_GROUP, trigger); /** * 列出在运行的触发器 * @return */ public String[] listTrigger(){ String[] triggers = new String[]{}; String[] triggerGroups = new String[]{}; try { triggerGroups = scheduler.getTriggerGroupNames(); for (int i = 0; i < triggerGroups.length; i++) { triggers = scheduler.getTriggerNames(triggerGroups[i]); } } catch (SchedulerException e) { e.printStackTrace(); } return triggers; } /** * 根据触发器得到表达式 * @param triggerName * @return */ public String takeCronByTriggerName(String triggerName){ String cron = ""; try { CronTriggerBean trigger = (CronTriggerBean) scheduler.getTrigger( triggerName, Scheduler.DEFAULT_GROUP); cron = trigger.getCronExpression(); } catch (SchedulerException e) { e.printStackTrace(); } return cron; } /** * 根据触发器得到任务运行状态 * @param triggerName * @return */ public int takeStateByTriggerName(String triggerName){ int state = 0 ; try { state = scheduler.getTriggerState(triggerName, Scheduler.DEFAULT_GROUP); } catch (SchedulerException e) { e.printStackTrace(); } return state; } /** * 开关任务 * @param type 1:关闭任务 2:开启任务 * @param triggerName * @param cronExpression * @return */ public boolean controlTrigger(String type,String triggerName,String cronExpression){ boolean flag = false; try { if("1".equals(type)){ String[] triggerGroups = new String[]{}; triggerGroups = scheduler.getTriggerGroupNames(); for (int i = 0; i < triggerGroups.length; i++) { // 停止job scheduler.pauseTrigger(triggerName, triggerGroups[i]); } }else{ // 重启job scheduler.resumeTrigger(triggerName, Scheduler.DEFAULT_GROUP); } flag = true; } catch (SchedulerException e) { e.printStackTrace(); } return flag; }
a123456678 2019-12-02 02:10:56 0 浏览量 回答数 0

回答

读取几十万行记得逐行读取,然后将返回的emailList拼接起来,不然一次性全部读取几十万行会出问题Code : /** * 域名后缀维护列表,为保证匹配准确度,仅匹配域名列表里有的邮箱 * 例如 sf@sf.ggadmin@,help@admin.sf.gg 都可以被正确匹配 * sf@sf.gggame@google.com 也可以正确拆分为 sf@sf.gg 和 game@google.com * 以下域名列表请自行按需添加, | 是间隔符 * * @param str 传入的含有邮箱的字符串 * @return emailList 已提取的邮箱列表 * @author Levey * @time 16/1/20 14:35 */ private static List getEmailList(String str) { //在此维护域名后缀表 String dn = "com|cn|org|com.cn|xyz|net|gg|gov.cn|love"; Pattern p = Pattern.compile("[\\w[.-]]+@[\\w[.-]]+\\.(" + dn + ")"); //邮箱验证 Matcher m = p.matcher(str); List<String> emailList = new ArrayList<>(); while (m.find()) { //update 2016-1-21 10:03:45 //去除包涵连续两个点的邮箱 if(!m.group().contains("..")) { emailList.add(m.group()); } } return emailList; } Test: public static void main(String args[]) { String str = "tencent.sf.gg@10000@qq.comghghghghg\n" + "你好leveychen,lev;levey-chen@myema你aaa@this.gov.cn好il.gmail.com悲" + "剧help@admin.sf.gg了" + "啊m@levey.com.cnmnihao的都是</br>和<sf@sf.gggame@google.com>"; System.out.println(getEmailList(str)); } Output:
蛮大人123 2019-12-02 02:03:46 0 浏览量 回答数 0

回答

得用post方式可以看http://www.shangxueba.com/jingyan/1846773.html 给你分享一个Android访问http的函数,超级好用哦 public class MyHttpClient { /** * 通过HttpClient发送GET请求 * @param path 请求路径 * @param params 请求参数 * @param ecoding 请求编码 * @return 请求是否成功 */ public HttpResponse sendHttpClientGETRequest(String path,Map<String, String> params, String ecoding) throws Exception { StringBuilder url=new StringBuilder(path); url.append("?"); for (Map.Entry<String, String> entry : params.entrySet()) { url.append(entry.getKey()).append("="); url.append(URLEncoder.encode(entry.getValue(),ecoding)); url.append("&"); } url.deleteCharAt(url.length()-1); HttpGet httpGet=new HttpGet(url.toString()); DefaultHttpClient client=new DefaultHttpClient(); client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 10000); client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 10000); HttpResponse response=client.execute(httpGet); if(response.getStatusLine().getStatusCode()==200){ return response; } return null; } /** * 通过HttpClient发送Post请求 * @param path 请求路径 * @param params 请求参数 * @param ecoding 请求编码 * @return 请求是否成功 */ public HttpResponse sendHttpClientPOSTRequest(String path, Map<String, String> params, String ecoding) throws Exception { List<NameValuePair> pair=new ArrayList<NameValuePair>();//存放请求参数 if(params!=null && !params.isEmpty()){ for (Map.Entry<String, String> entry : params.entrySet()) { pair.add(new BasicNameValuePair(entry.getKey(),entry.getValue())); } } UrlEncodedFormEntity enFormEntity=new UrlEncodedFormEntity(pair,ecoding); HttpPost httpPost=new HttpPost(path); httpPost.setEntity(enFormEntity); DefaultHttpClient client=new DefaultHttpClient(); client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 10000); client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 10000); HttpResponse response=client.execute(httpPost); if(response.getStatusLine().getStatusCode()==200){ return response; } return null; } /** * 通过HttpClient发送Post请求 * @param path 请求路径 * @param params 请求参数 * @param ecoding 请求编码 * @return 请求是否成功 */ public HttpResponse sendHttpClientPOSTRequest(String path, Map<String, String> params, String ecoding, int timeout) throws Exception { List<NameValuePair> pair=new ArrayList<NameValuePair>();//存放请求参数 if(params!=null && !params.isEmpty()){ for (Map.Entry<String, String> entry : params.entrySet()) { pair.add(new BasicNameValuePair(entry.getKey(),entry.getValue())); } } UrlEncodedFormEntity enFormEntity=new UrlEncodedFormEntity(pair,ecoding); HttpPost httpPost=new HttpPost(path); httpPost.setEntity(enFormEntity); DefaultHttpClient client=new DefaultHttpClient(); client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout); client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout); HttpResponse response=client.execute(httpPost); if(response.getStatusLine().getStatusCode()==200){ return response; } return null; } }
杨冬芳 2019-12-02 03:03:24 0 浏览量 回答数 0

回答

试试看: private static final String SECRET_AES = "AES"; private static final String SECRET_PATTERN_ECB = "AES/ECB/PKCS5Padding"; private static final String CODE = "UTF-8"; private static Cipher cipher; private static SecretKeySpec secretKey; /*** * AES加密 * * @param value * @param key * @return */ public static byte[] _encode(String value, String key) { try { byte[] bs = key.getBytes(CODE); secretKey = new SecretKeySpec(bs, SECRET_AES); cipher = Cipher.getInstance(SECRET_PATTERN_ECB); cipher.init(Cipher.ENCRYPT_MODE, secretKey); return cipher.doFinal(value.getBytes(CODE)); } catch (Exception e) { return null; } } /*** * AES解密 * * @param value * @param key * @return */ public static String _decode(byte[] value, String key) { try { byte[] bs = key.getBytes(CODE); secretKey = new SecretKeySpec(bs, SECRET_AES); cipher = Cipher.getInstance(SECRET_PATTERN_ECB); cipher.init(Cipher.DECRYPT_MODE, secretKey); byte[] decrypt = cipher.doFinal(value); return new String(decrypt); } catch (Exception e) { return null; } }
爵霸 2019-12-02 02:08:16 0 浏览量 回答数 0

问题

ios 声明变量提问

请问,声明这两个地方的变量,有什么不一样么? 全选复制放进笔记#import @interface People : NSObject{ NSString* a;//这里的变量} @property BOOL flag; @prope...
a123456678 2019-12-01 20:28:06 805 浏览量 回答数 1

回答

建立一个无生命周期的cookie,即随着浏览器的关闭即消失的cookie,代码如下 HttpServletRequest request HttpServletResponse response Cookie cookie = new Cookie("cookiename","cookievalue"); response.addCookie(cookie); 下面建立一个有生命周期的cookie,可以设置他的生命周期 cookie = new Cookie("cookiename","cookievalue"); cookie.setMaxAge(3600); //设置路径,这个路径即该工程下都可以访问该cookie 如果不设置路径,那么只有设置该cookie路径及其子路径可以访问 cookie.setPath("/"); response.addCookie(cookie); 下面介绍如何读取cookie,读取cookie代码如下 Cookie[] cookies = request.getCookies();//这样便可以获取一个cookie数组 for(Cookie cookie : cookies){ cookie.getName();// get the cookie name cookie.getValue(); // get the cookie value } 上面就是基本的读写cookie的操作。我们在实际中最好进行一下封装,比如增加一个cookie,我们关注的是cookie的name,value,生命周期,所以进行封装一个函数,当然还要传入一个response对象,addCookie()代码如下 /** * 设置cookie * @param response * @param name cookie名字 * @param value cookie值 * @param maxAge cookie生命周期 以秒为单位 */ public static void addCookie(HttpServletResponse response,String name,String value,int maxAge){ Cookie cookie = new Cookie(name,value); cookie.setPath("/"); if(maxAge>0) cookie.setMaxAge(maxAge); response.addCookie(cookie); } 读取cookie的时候,为了方便我们的操作,我们希望封装一个函数,只要我们提供cookie的name,我们便可以获取cookie的value,带着这个想法,很容易想到将cookie封装到Map里面,于是进行下面的封装 /** * 根据名字获取cookie * @param request * @param name cookie名字 * @return */ public static Cookie getCookieByName(HttpServletRequest request,String name){ Map<String,Cookie> cookieMap = ReadCookieMap(request); if(cookieMap.containsKey(name)){ Cookie cookie = (Cookie)cookieMap.get(name); return cookie; }else{ return null; } } /** * 将cookie封装到Map里面 * @param request * @return */ private static Map<String,Cookie> ReadCookieMap(HttpServletRequest request){ Map<String,Cookie> cookieMap = new HashMap<String,Cookie>(); Cookie[] cookies = request.getCookies(); if(null!=cookies){ for(Cookie cookie : cookies){ cookieMap.put(cookie.getName(), cookie); } } return cookieMap; }
蛮大人123 2019-12-02 02:21:45 0 浏览量 回答数 0

回答

这个注解应该可以实现你要的东西,建议你多看看spring的reference。 @RequestMapping("/query") public String query(@ModelAttribute String param1,@ModelAttribute String param2) { return "pageList"; }
a123456678 2019-12-02 02:09:34 0 浏览量 回答数 0

回答

您可以implicit像这样使用scala 类。 package utilityimport org.apache.commons.lang3.StringUtilsimport org.apache.spark.sql.Row import scala.util.{Failure, Success, Try} object MyRowExtensions { /** * RowExt. * * @param row */ implicit class RowExt(row: Row) { /** * anyEmptyString * * @return Boolean */ def anyEmptyString(): Boolean = { val len = row.length var i = 0 while (i < len) { if (StringUtils.isEmpty(row.get(i).toString)) { return true } i += 1 } false } /** * anyString * * @param str * @return Boolean */ def anyStringMatched(matchStr: String): Boolean = { val len = row.length var i = 0 while (i < len) { if (row.get(i).toString == matchStr) { return true } i += 1 } false } /** * getAsOption * * @param fieldName * @tparam T * @return Option[T] */ def getAsOption[T](fieldName: String): Option[T] = { Try(row.getAs[T](fieldName)) match { case Success(value) => Some(value) case Failure(e) => None } } } }看起来这样...... import utility.MyRowExtensions.RowExt myDataFrame.map(r => r.anyStringMatched("myteststring")).showmyDataFrame.filter(_.anyEmptyString).show
社区小助手 2019-12-02 01:50:54 0 浏览量 回答数 0

回答

通过HTTP协议,这是代码参考,是以同步方式进行网络访问的,返回验证码为200就是请求成功!然后通过JSON进行数据传送!希望可以帮助你!/****以同步方式发送Http请求*/ public class SyncHttp { /** * 通过GET方式发送请求 * @param url URL地址 * @param params 参数 * @return * @throws Exception */ public String httpGet(String url, String params) throws Exception { String response = null; //返回信息 //拼接请求URL if (null!=params&&!params.equals("")) { url += "?" + params; } int timeoutConnection = 3000; int timeoutSocket = 5000; HttpParams httpParameters = new BasicHttpParams();// Set the timeout in milliseconds until a connection is established. HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);// Set the default socket timeout (SO_TIMEOUT) // in milliseconds which is the timeout for waiting for data. HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket); // 构造HttpClient的实例 HttpClient httpClient = new DefaultHttpClient(httpParameters); // 创建GET方法的实例 HttpGet httpGet = new HttpGet(url); try { HttpResponse httpResponse = httpClient.execute(httpGet); int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode == HttpStatus.SC_OK) //SC_OK = 200 { // 获得返回结果 response = EntityUtils.toString(httpResponse.getEntity()); } else { response = "返回码:"+statusCode; } } catch (Exception e) { throw new Exception(e); } return response; } /** * 通过POST方式发送请求 * @param url URL地址 * @param params 参数 * @return * @throws Exception */ public String httpPost(String url, List<Parameter> params) throws Exception { String response = null; int timeoutConnection = 3000; int timeoutSocket = 5000; HttpParams httpParameters = new BasicHttpParams();// Set the timeout in milliseconds until a connection is established. HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);// Set the default socket timeout (SO_TIMEOUT) // in milliseconds which is the timeout for waiting for data. HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket); // 构造HttpClient的实例 HttpClient httpClient = new DefaultHttpClient(httpParameters); HttpPost httpPost = new HttpPost(url); if (params.size()>=0) { //设置httpPost请求参数 httpPost.setEntity(new UrlEncodedFormEntity(buildNameValuePair(params),HTTP.UTF_8)); } //使用execute方法发送HTTP Post请求,并返回HttpResponse对象 HttpResponse httpResponse = httpClient.execute(httpPost); int statusCode = httpResponse.getStatusLine().getStatusCode(); if(statusCode==HttpStatus.SC_OK) { //获得返回结果 response = EntityUtils.toString(httpResponse.getEntity()); } else { response = "返回码:"+statusCode; } return response; } /** * 把Parameter类型集合转换成NameValuePair类型集合 * @param params 参数集合 * @return */ private List<BasicNameValuePair> buildNameValuePair(List<Parameter> params) { List<BasicNameValuePair> result = new ArrayList<BasicNameValuePair>(); for (Parameter param : params) { BasicNameValuePair pair = new BasicNameValuePair(param.getName(), param.getValue()); result.add(pair); } return result; } }
a123456678 2019-12-02 02:03:39 0 浏览量 回答数 0

回答

用这个RadioGroup,在radiogroup里面写布局,随便怎么布局radiobutton都可以 package com.xhbok.shundai.view; import android.annotation.SuppressLint; import android.content.Context; import android.content.res.TypedArray; import android.os.Build; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.CompoundButton; import android.widget.LinearLayout; import android.widget.RadioButton; import java.util.ArrayList; import java.util.List; public class MutilRadioGroup extends LinearLayout { // holds the checked id; the selection is empty by default private int mCheckedId = -1; // tracks children radio buttons checked state private CompoundButton.OnCheckedChangeListener mChildOnCheckedChangeListener; // when true, mOnCheckedChangeListener discards events private boolean mProtectFromCheckedChange = false; private OnCheckedChangeListener mOnCheckedChangeListener; private PassThroughHierarchyChangeListener mPassThroughListener; /** * {@inheritDoc} */ public MutilRadioGroup(Context context) { super(context); setOrientation(VERTICAL); init(); } /** * {@inheritDoc} */ public MutilRadioGroup(Context context, AttributeSet attrs) { super(context, attrs); init(); } private void init() { mChildOnCheckedChangeListener = new CheckedStateTracker(); mPassThroughListener = new PassThroughHierarchyChangeListener(); super.setOnHierarchyChangeListener(mPassThroughListener); } /** * {@inheritDoc} */ @Override public void setOnHierarchyChangeListener(OnHierarchyChangeListener listener) { // the user listener is delegated to our pass-through listener mPassThroughListener.mOnHierarchyChangeListener = listener; } /** * set the default checked radio button, without notification the listeners */ public void setCheckWithoutNotif(int id){ if (id != -1 && (id == mCheckedId)) { return; } mProtectFromCheckedChange = true; if (mCheckedId != -1) { setCheckedStateForView(mCheckedId, false); } if (id != -1) { mProtectFromCheckedChange = true; } mProtectFromCheckedChange = false; mCheckedId = id; } @Override public void addView(View child, int index, ViewGroup.LayoutParams params) { List<RadioButton> btns = getAllRadioButton(child); if(btns != null && btns.size() > 0){ for(RadioButton button : btns){ if (button.isChecked()) { mProtectFromCheckedChange = true; if (mCheckedId != -1) { setCheckedStateForView(mCheckedId, false); } mProtectFromCheckedChange = false; setCheckedId(button.getId()); } } } super.addView(child, index, params); } /** * get all radio buttons which are in the view * @param child */ private List<RadioButton> getAllRadioButton(View child){ List<RadioButton> btns = new ArrayList<RadioButton>(); if (child instanceof RadioButton) { btns.add((RadioButton) child); }else if(child instanceof ViewGroup){ int counts = ((ViewGroup) child).getChildCount(); for(int i = 0; i < counts; i++){ btns.addAll(getAllRadioButton(((ViewGroup) child).getChildAt(i))); } } return btns; } /** * <p>Sets the selection to the radio button whose identifier is passed in * parameter. Using -1 as the selection identifier clears the selection; * such an operation is equivalent to invoking {@link #clearCheck()}.</p> * * @param id the unique id of the radio button to select in this group * * @see #getCheckedRadioButtonId() * @see #clearCheck() */ public void check(int id) { // don't even bother if (id != -1 && (id == mCheckedId)) { return; } if (mCheckedId != -1) { setCheckedStateForView(mCheckedId, false); } if (id != -1) { setCheckedStateForView(id, true); } setCheckedId(id); } private void setCheckedId(int id) { mCheckedId = id; if (mOnCheckedChangeListener != null) { mOnCheckedChangeListener.onCheckedChanged(this, mCheckedId); } } private void setCheckedStateForView(int viewId, boolean checked) { View checkedView = findViewById(viewId); if (checkedView != null && checkedView instanceof RadioButton) { ((RadioButton) checkedView).setChecked(checked); } } /** * <p>Returns the identifier of the selected radio button in this group. * Upon empty selection, the returned value is -1.</p> * * @return the unique id of the selected radio button in this group * * @see #check(int) * @see #clearCheck() * * @attr ref android.R.styleable#MyRadioGroup_checkedButton */ public int getCheckedRadioButtonId() { return mCheckedId; } /** * <p>Clears the selection. When the selection is cleared, no radio button * in this group is selected and {@link #getCheckedRadioButtonId()} returns * null.</p> * * @see #check(int) * @see #getCheckedRadioButtonId() */ public void clearCheck() { check(-1); } /** * <p>Register a callback to be invoked when the checked radio button * changes in this group.</p> * * @param listener the callback to call on checked state change */ public void setOnCheckedChangeListener(OnCheckedChangeListener listener) { mOnCheckedChangeListener = listener; } /** * {@inheritDoc} */ @Override public LayoutParams generateLayoutParams(AttributeSet attrs) { return new LayoutParams(getContext(), attrs); } /** * {@inheritDoc} */ @Override protected boolean checkLayoutParams(ViewGroup.LayoutParams p) { return p instanceof LayoutParams; } @Override protected LinearLayout.LayoutParams generateDefaultLayoutParams() { return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); } @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setClassName(MutilRadioGroup.class.getName()); } @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); info.setClassName(MutilRadioGroup.class.getName()); } /** * <p>This set of layout parameters defaults the width and the height of * the children to {@link #WRAP_CONTENT} when they are not specified in the * XML file. Otherwise, this class ussed the value read from the XML file.</p> * * <p>See * for a list of all child view attributes that this class supports.</p> * */ public static class LayoutParams extends LinearLayout.LayoutParams { /** * {@inheritDoc} */ public LayoutParams(Context c, AttributeSet attrs) { super(c, attrs); } /** * {@inheritDoc} */ public LayoutParams(int w, int h) { super(w, h); } /** * {@inheritDoc} */ public LayoutParams(int w, int h, float initWeight) { super(w, h, initWeight); } /** * {@inheritDoc} */ public LayoutParams(ViewGroup.LayoutParams p) { super(p); } /** * {@inheritDoc} */ public LayoutParams(MarginLayoutParams source) { super(source); } /** * <p>Fixes the child's width to * {@link ViewGroup.LayoutParams#WRAP_CONTENT} and the child's * height to {@link ViewGroup.LayoutParams#WRAP_CONTENT} * when not specified in the XML file.</p> * * @param a the styled attributes set * @param widthAttr the width attribute to fetch * @param heightAttr the height attribute to fetch */ @Override protected void setBaseAttributes(TypedArray a, int widthAttr, int heightAttr) { if (a.hasValue(widthAttr)) { width = a.getLayoutDimension(widthAttr, "layout_width"); } else { width = WRAP_CONTENT; } if (a.hasValue(heightAttr)) { height = a.getLayoutDimension(heightAttr, "layout_height"); } else { height = WRAP_CONTENT; } } } /** * <p>Interface definition for a callback to be invoked when the checked * radio button changed in this group.</p> */ public interface OnCheckedChangeListener { /** * <p>Called when the checked radio button has changed. When the * selection is cleared, checkedId is -1.</p> * * @param group the group in which the checked radio button has changed * @param checkedId the unique identifier of the newly checked radio button */ public void onCheckedChanged(MutilRadioGroup group, int checkedId); } private class CheckedStateTracker implements CompoundButton.OnCheckedChangeListener { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // prevents from infinite recursion if (mProtectFromCheckedChange) { return; } mProtectFromCheckedChange = true; if (mCheckedId != -1) { setCheckedStateForView(mCheckedId, false); } mProtectFromCheckedChange = false; int id = buttonView.getId(); setCheckedId(id); } } /** * <p>A pass-through listener acts upon the events and dispatches them * to another listener. This allows the table layout to set its own internal * hierarchy change listener without preventing the user to setup his.</p> */ private class PassThroughHierarchyChangeListener implements OnHierarchyChangeListener { private OnHierarchyChangeListener mOnHierarchyChangeListener; /** * {@inheritDoc} */ @SuppressLint("NewApi") public void onChildViewAdded(View parent, View child) { if (parent == MutilRadioGroup.this ) { List<RadioButton> btns = getAllRadioButton(child); if(btns != null && btns.size() > 0){ for(RadioButton btn : btns){ int id = btn.getId(); // generates an id if it's missing if (id == View.NO_ID && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { id = View.generateViewId(); btn.setId(id); } btn.setOnCheckedChangeListener( mChildOnCheckedChangeListener); } } } if (mOnHierarchyChangeListener != null) { mOnHierarchyChangeListener.onChildViewAdded(parent, child); } } /** * {@inheritDoc} */ public void onChildViewRemoved(View parent, View child) { if (parent == MutilRadioGroup.this) { List<RadioButton> btns = getAllRadioButton(child); if(btns != null && btns.size() > 0){ for(RadioButton btn : btns){ btn.setOnCheckedChangeListener(null); } } } if (mOnHierarchyChangeListener != null) { mOnHierarchyChangeListener.onChildViewRemoved(parent, child); } } } }
爵霸 2019-12-02 02:15:37 0 浏览量 回答数 0

回答

/** * 给pdf文件添加水印 * @param InPdfFile 要加水印的原pdf文件路径 * @param outPdfFile 加了水印后要输出的路径 * @param markImagePath 水印图片路径 * @param pageSize 原pdf文件的总页数(该方法是我当初将数据导入excel中然后再转换成pdf所以我这里的值是用excel的行数计算出来的,如果不是我这种可以 直接用reader.getNumberOfPages()获取pdf的总页数) * @throws Exception */ public static void addPdfMark(String InPdfFile, String outPdfFile, String markImagePath, int pageSize) throws Exception { PdfReader reader = new PdfReader(InPdfFile, "PDF".getBytes()); PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(outPdfFile)); Image img = Image.getInstance(markImagePath);// 插入水印 img.setAbsolutePosition(150, 100); for(int i = 1; i <= pageSize; i++) { PdfContentByte under = stamp.getUnderContent(i); under.addImage(img); } stamp.close();// 关闭 File tempfile = new File(InPdfFile); if(tempfile.exists()) { tempfile.delete(); } } 所需jar包iText-2.0.8.jar
蛮大人123 2019-12-02 02:18:16 0 浏览量 回答数 0

回答

详细解答可以参考官方帮助文档 请参照以下代码完成SDK的初始化,appKey/appSecret的获取参考创建App;注意:百川云推送迁移来的用户,不要使用百川平台获取到的appKey/appSecret,参考上述链接从阿里云平台获取,否则会发生鉴权错误。 > iOS 10系统的设备需注意,源于工信部的要求,国行手机首次安装App时,会弹出一个询问用户“是否允许应用访问数据”的弹框,如下图所示。在用户点击允许前,或点击不允许,App的网络环境是不通的,会导致推送SDK的初始化失败,推送服务不能正常使用。推送各接口内部是有重试机制的,但是,建议用户在业务层,也要捕获处理SDK接口错误回调,确保正确获知SDK接口调用状态。 - (void)initCloudPush { // SDK初始化 [CloudPushSDK asyncInit:@"*****" appSecret:@"*****" callback:^(CloudPushCallbackResult *res) { if (res.success) { NSLog(@"Push SDK init success, deviceId: %@.", [CloudPushSDK getDeviceId]); } else { NSLog(@"Push SDK init failed, error: %@", res.error); } }];} 向苹果APNs注册获取deviceToken并上报到阿里云推送服务器; /** * 注册苹果推送,获取deviceToken用于推送 * * @param application */- (void)registerAPNS:(UIApplication *)application { if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { // iOS 8 Notifications [application registerUserNotificationSettings: [UIUserNotificationSettings settingsForTypes: (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; [application registerForRemoteNotifications]; } else { // iOS < 8 Notifications [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)]; }}/* * 苹果推送注册成功回调,将苹果返回的deviceToken上传到CloudPush服务器 */- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [CloudPushSDK registerDevice:deviceToken withCallback:^(CloudPushCallbackResult *res) { if (res.success) { NSLog(@"Register deviceToken success."); } else { NSLog(@"Register deviceToken failed, error: %@", res.error); } }];}/* * 苹果推送注册失败回调 */- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { NSLog(@"didFailToRegisterForRemoteNotificationsWithError %@", error);} 推送消息到来监听; /** * 注册推送消息到来监听 */- (void)registerMessageReceive { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMessageReceived:) name:@"CCPDidReceiveMessageNotification" object:nil];}/** * 处理到来推送消息 * * @param notification */- (void)onMessageReceived:(NSNotification *)notification { CCPSysMessage *message = [notification object]; NSString *title = [[NSString alloc] initWithData:message.title encoding:NSUTF8StringEncoding]; NSString *body = [[NSString alloc] initWithData:message.body encoding:NSUTF8StringEncoding]; NSLog(@"Receive message title: %@, content: %@.", title, body);} 通知打开监听: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // 点击通知将App从关闭状态启动时,将通知打开回执上报 // [CloudPushSDK handleLaunching:launchOptions];(Deprecated from v1.8.1) [CloudPushSDK sendNotificationAck:launchOptions]; return YES;}/* * App处于启动状态时,通知打开回调 */- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo { NSLog(@"Receive one notification."); // 取得APNS通知内容 NSDictionary *aps = [userInfo valueForKey:@"aps"]; // 内容 NSString *content = [aps valueForKey:@"alert"]; // badge数量 NSInteger badge = [[aps valueForKey:@"badge"] integerValue]; // 播放声音 NSString *sound = [aps valueForKey:@"sound"]; // 取得Extras字段内容 NSString *Extras = [userInfo valueForKey:@"Extras"]; //服务端中Extras字段,key是自己定义的 NSLog(@"content = [%@], badge = [%ld], sound = [%@], Extras = [%@]", content, (long)badge, sound, Extras); // iOS badge 清0 application.applicationIconBadgeNumber = 0; // 通知打开回执上报 // [CloudPushSDK handleReceiveRemoteNotification:userInfo];(Deprecated from v1.8.1) [CloudPushSDK sendNotificationAck:userInfo];} 如果使用推送模块,请参考移动推送常见问题
2019-12-01 23:11:51 0 浏览量 回答数 0

回答

栈是后进先出,只要记住这一点,就不难实现。下面是我的实现: /** * StackByArray:数组方式实现栈,实现栈的初始化,入栈出栈操作 * * @author zeng.xiangdong 1770534116@qq.com * @version V1.0 2014-8-24 下午10:00:03 */ public class StackByArray { // 栈的长度 private int length; // 栈 private Object[] array; // 栈顶的下标 private int topIndex = -1; /** * StackByArry:构造方法 * * @param length 初始化栈的长度 */ public StackByArray(int length) { this.length = length; array = new Object[length]; } /** * push:入栈 * * @param obj * @throws Exception */ private void push(Object obj) throws Exception { if(isFullStack()) { throw new Exception("栈已满"); } array[++topIndex] = obj; } /** * offer: 出栈,取出栈顶元素 * * @return obj * @throws Exception */ private Object offer() throws Exception { if(isEmptyStack()) { throw new Exception("栈已空"); } Object topObject = array[topIndex]; array[topIndex] = null; topIndex--; return topObject; } /** * isEmptyStack:判断栈是否为空 * * @return */ private boolean isEmptyStack() { return (topIndex == -1); } /** * isFullStack:判断栈是否已满 * * @return */ private boolean isFullStack() { return topIndex == (length - 1); } /** * getLength:取得栈内的数据长度 * * @return length */ private int getLength() { return topIndex + 1; } /** * outPut:栈内容输出 */ private void outPut() { for(Object obj : array) { if(obj != null) { System.out.print(obj + ", "); } } System.out.println(); } /** * main:(这里用一句话描述这个方法的作用) * * @param args */ public static void main(String[] args) throws Exception { StackByArray stack = new StackByArray(10); for(int i = 1; i <= 8; i++) { stack.push(i); stack.outPut(); } System.out.println("---------------"); System.out.println(stack.offer()); stack.outPut(); System.out.println("---------------"); System.out.println(stack.offer()); stack.outPut(); System.out.println(stack.getLength()); } }
蛮大人123 2019-12-02 02:15:06 0 浏览量 回答数 0

问题

java源码中一个抽象类初始化方法中包含一个super(),该怎么理解

import java.util.Set; /** * Abstract base class for parameter collections. * Type specific setters and getters are map...
蛮大人123 2019-12-01 20:24:04 1811 浏览量 回答数 1

云产品推荐

上海奇点人才服务相关的云产品 小程序定制 上海微企信息技术相关的云产品 国内短信套餐包 ECS云服务器安全配置相关的云产品 开发者问答 阿里云建站 自然场景识别相关的云产品 万网 小程序开发制作 视频内容分析 视频集锦 代理记账服务