我从我的网络服务中获取数据
ArrayList<HashMap<String,String>>
Run Code Online (Sandbox Code Playgroud)
现在我想将上面的每个对象转换为
String[]
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?任何帮助将非常感激!
我已将listview适配器的代码包含在下面所有工作正常,但图像未从网址加载.可能是这样的.我正在使用Android查询库来加载图片.
public Onadapter(Context context,String[] id,String[] label,String[] title,String[] image,String[] hrs,String[] posted_date)
{
this.context=context;
this.id = id;
this.label = label;
this.title = title;
this.image = image;
this.hrs = hrs;
this.posted_date=posted_date;
}
private class ViewHolder{
ImageView img;
TextView id;
TextView label;
TextView title;
TextView hrs;
TextView posted_date;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.whatslist, null);
holder = new ViewHolder();
holder.id=(TextView) convertView.findViewById(R.id.whats_id);
holder.img = …Run Code Online (Sandbox Code Playgroud) 我编写了一个 json 解析器类来解析一个从 http 请求返回的简单 json 数组。我如何修改下面的代码以从 url请求 URL 的对象“条目”中获取数据
try {
JSONArray jArray = new JSONArray(result);
JSONObject json_data = null;
for (int i = 0; i < jArray.length(); i++) {
json_data = jArray.getJSONObject(i);
String title = json_data.getString("title");
String link=json_data.getString("link");
HashMap<String, String>map=new HashMap<String, String>();
map.put("title",title);
map.put("link",link);
jlist.add(map);
}
Run Code Online (Sandbox Code Playgroud)
回复:
{
"responseData": {
"feed": {
"feedUrl": "http://ramrojob.com/feed",
"title": "Ramro Job",
"link": "http://ramrojob.com",
"author": "",
"description": "...your pathway to success",
"type": "rss20",
"entries": [
{
"title": "Monitoring and Evaluation Specialist …Run Code Online (Sandbox Code Playgroud) 我有一个对象列表.
例如>
groupId = 1 name = name1
groupId = 1 name = name2
groupId = 1 name = name3
groupId = 2 name = name4
List中的多个对象具有相同的值groupId.我需要创建具有相同对象的子列表groupId.我如何用Java做到这一点.
我的Inital想法是创造一个,HashMap<Integer,List<Object>>但我不确定groupIds进入的不确定值,这反过来让我不确定如何将对象与hashmap的键groupIds组合在一起groupId.
如果groupId将来不会改变或增加,我可以迭代原始列表并编写一个switch语句来创建所需的数组.