标签:android style http color io os ar java for
============问题描述============
Thread myThread = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					Map<String, String> map1 = new HashMap<String, String>();
					map1.put("", "");
					String retStr = "";
					retStr = NetTool.sendGetRequest(messageShowUrl, map1,
							"utf-8");
					String[] str = retStr.split(",");
					list = Arrays.asList(str);
					listAll.clear();
					for (int i = 0; i < str.length / 5; i++) {
						Map<String, Object> map2 = new HashMap<String, Object>();
						map2.put("user_name", list.get(i * 5));
						map2.put("object_words", list.get(i * 5 + 1));
						map2.put("my_words", list.get(i * 5 + 2));
						map2.put("date", list.get(i * 5 + 4));
						// 如果用户没有传照片,map2中传的imageUrl就为空
						System.out.println("list3 = " + list.get(i * 5 + 3));
						if (!list.get(i * 5 + 3).equals(" ")) {
							String imageUrl1 = "http://10.0.2.2:8080/BBStuServlet/"
									+ list.get(i * 5 + 3);
							String imageUrl = imageUrl1.replace(" ", "");
							map2.put("imageUrl", imageUrl);
						} else {
							map2.put("imageUrl", "");
						}
						listAll.add(map2);
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
		myThread.start();
		MyAdapter adapter = new MyAdapter(this);
		messageList.setAdapter(adapter);
Thread myThread = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					Map<String, String> map1 = new HashMap<String, String>();
					map1.put("", "");
					String retStr = "";
					retStr = NetTool.sendGetRequest(messageShowUrl, map1,
							"utf-8");
					String[] str = retStr.split(",");
					list = Arrays.asList(str);
					listAll.clear();
					synchronized (this) {
						for (int i = 0; i < str.length / 5; i++) {
							Map<String, Object> map2 = new HashMap<String, Object>();
							map2.put("user_name", list.get(i * 5));
							map2.put("object_words", list.get(i * 5 + 1));
							map2.put("my_words", list.get(i * 5 + 2));
							map2.put("date", list.get(i * 5 + 4));
							// 如果用户没有传照片,map2中传的imageUrl就为空
							System.out.println("list3 = " + list.get(i * 5 + 3));
							if (!list.get(i * 5 + 3).equals(" ")) {
								String imageUrl1 = "http://10.0.2.2:8080/BBStuServlet/"
										+ list.get(i * 5 + 3);
								String imageUrl = imageUrl1.replace(" ", "");
								map2.put("imageUrl", imageUrl);
							} else {
								map2.put("imageUrl", "");
							}
							listAll.add(map2);
						}
						notifyAll();
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
		myThread.start();
		synchronized (myThread) {
			try {
				myThread.wait();
				MyAdapter adapter = new MyAdapter(this);
				messageList.setAdapter(adapter);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}============解决方案1============
============解决方案2============
标签:android style http color io os ar java for
原文地址:http://www.cnblogs.com/meizhenfen42/p/4033935.html