团队冲刺二(5)
5.29日
朴远东:学习ListView(一),理解Adaper适配器。
package com.example.toas;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.ArrayList;
public class MyNoteAdapter extends BaseAdapter {
private Context context;
private ArrayList<MyNoteBean> listData;
public MyNoteAdapter(Context context,ArrayList<MyNoteBean> listData){
this.context=context;
this.listData=listData;
}
@Override
public int getCount() { return listData.size(); }
@Override
public Object getItem(int position) { return listData.get(position); }
@Override
public long getItemId(int position) { return position; }
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder=null;
if(convertView==null){
LayoutInflater inflater=LayoutInflater.from(context);
//这里将ListView的格式xml文件名称写入,名字千万别写错,否则调用后显示的格式会发生错误
convertView=inflater.inflate(R.layout.list_item,null);
viewHolder=new ViewHolder();
viewHolder.li_title=(TextView)convertView.findViewById(R.id.li_title);
viewHolder.li_kemu=(TextView)convertView.findViewById(R.id.li_kemu);
convertView.setTag(viewHolder);
}
viewHolder=(ViewHolder)convertView.getTag();
MyNoteBean model=listData.get(position);
viewHolder.li_title.setText(model.getTitle());
viewHolder.li_kemu.setText(model.getKemu());
return convertView;
}
}
class ViewHolder{
public TextView li_title;
public TextView li_kemu;
}
——————
张宏伟:研究app应用跳转,发现新大陆
final String qqUrl = "mqqwpa://im/chat?chat_type=wpa&uin=100000&version=1";findViewById(R.id.ll_online_qq).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(qqUrl))); }});
可直接跳转至QQ。
王兵兵:完善记笔记的信息录入,整合朴远东更改后的图片路径管理,更改数据库格式
private boolean testFile(HttpServletRequest request)
{
boolean flag=false;
Note note=new Note();
Map<String, String> fileMap=new HashMap<String, String>();
String title=request.getParameter("title");
String see=request.getParameter("see");
String kemu=request.getParameter("kemu");
String userID=request.getParameter("userID");
int userId=Integer.valueOf(userID);
System.out.println("标题:"+title);
System.out.println("是否公开:"+see);
System.out.println("科目:"+kemu);
System.out.println("用户ID:"+userId);
note.setTitle(title);
note.setCourse(kemu);
note.setPermission(see);
DiskFileItemFactory factory=new DiskFileItemFactory();
ServletFileUpload sfu=new ServletFileUpload(factory);
sfu.setFileSizeMax(30*1024*1024);
List<FileItem> list=null;
String path="G:/CloudNoteTry/";
String path1="";
Date t = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd");
String date=df.format(t);
String date_sql=df2.format(t);
note.setDate(date_sql);
int a=1;
try {
list = sfu.parseRequest(request);
} catch (FileUploadException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
return false;
}
for(FileItem fileItem:list)
{
if(fileItem.isFormField())
{
String filename=fileItem.getFieldName();
String value=null;
try {
value = fileItem.getString("utf-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
if(filename.equals("username"))
{
path=path+value;
path1=path1+value;
File file=new File(path);
if(!file.exists())
{
file.mkdir();
}
path=path+"/"+date;
path1=path1+"/"+date;
File file2=new File(path);
if(!file2.exists())
{
file2.mkdir();
}
}
System.out.println(filename+"="+value);
}
else
{
long size = fileItem.getSize();
//判断size是否为0
if(size==0){
continue;
}
//获取文件的类型
String contentType = fileItem.getContentType();
//获取文件的名字
String name = fileItem.getName();
String prefix = UUID.randomUUID().toString().replace("-", "");
name = prefix+"_"+name;
if(contentType.equals("text/plain"))
{
fileMap.put("txt_path",path1+"/"+name);
}
else
{
fileMap.put("image"+a+"_path",path1+"/"+name);
a++;
}
//获取表单项的属性名
String fieldName = fileItem.getFieldName();
System.out.println("文件的大小: "+size);
System.out.println("文件的类型: "+contentType);
System.out.println("文件的名字: "+name);
System.out.println("表单项name属性名: "+fieldName);
//将文件写入到磁盘中
try {
fileItem.write(new File(path+"/"+name));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
note.setFileMap(fileMap);
try {
userService=UserService.getUserService();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
flag=false;
}
flag=userService.addNote(note,userId);
return flag;
}等
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步