我有一个ArrayList,我在ArrayAdapter中使用ListView.我需要获取列表中的项目并将它们转换为JSONArray以发送到API.我已经四处寻找,但没有找到任何解释这可行的方法,任何帮助都会受到赞赏.
更新 - 解决方案
以下是我最终要解决的问题.
ArrayList中的对象:
public class ListItem {
private long _masterId;
private String _name;
private long _category;
public ListItem(long masterId, String name, long category) {
_masterId = masterId;
_name = name;
_category = category;
}
public JSONObject getJSONObject() {
JSONObject obj = new JSONObject();
try {
obj.put("Id", _masterId);
obj.put("Name", _name);
obj.put("Category", _category);
} catch (JSONException e) {
trace("DefaultListItem.toString JSONException: "+e.getMessage());
}
return obj;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我如何转换它:
ArrayList<ListItem> myCustomList = .... // list filled with objects
JSONArray jsonArray = …Run Code Online (Sandbox Code Playgroud) 我正在尝试在OSX上使用Apache2配置mod_mono.我想在同一个虚拟主机上运行多个MVC3项目,但由于某种原因,只有列出的第一个项目正在运行.对此有任何帮助将非常感激,因为没有太多关于此的文档.我尝试了很多不同的配置选项,但似乎都没有.
Listen *:9005
<VirtualHost *:9005>
DocumentRoot "/Library/WebServer/vhosts/api"
ServerName api
MonoAutoApplication disabled
Alias /gamecenter "/Library/WebServer/vhosts/api/gamecenter"
AddMonoApplications gamecenter "/gamecenter:/Library/WebServer/vhosts/api/gamecenter"
MonoServerPath gamecenter "/usr/bin/mod-mono-server4"
MonoDebug gamecenter true
MonoSetEnv gamecenter MONO_IOMAP=all
MonoUnixSocket gamecenter-stage /tmp/mod_mono_server_gc
<Location /gamecenter>
Allow from all
Order allow,deny
MonoSetServerAlias gamecenter
SetHandler mono
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary
</Location>
Alias /gamecenter-stage "/Library/WebServer/vhosts/api/gamecenter-stage"
MonoServerPath gamecenter-stage "/usr/bin/mod-mono-server4"
MonoDebug gamecenter-stage true
MonoSetEnv gamecenter-stage MONO_IOMAP=all
AddMonoApplications gamecenter-stage "/gamecenter-stage:/Library/WebServer/vhosts/api/gamecenter-stage"
MonoUnixSocket gamecenter-stage /tmp/mod_mono_server_gcs
<Location /gamecenter-stage>
Allow from all
Order allow,deny
MonoSetServerAlias gamecenter-stage
SetHandler mono
SetOutputFilter DEFLATE
SetEnvIfNoCase …Run Code Online (Sandbox Code Playgroud) 我有两个表,一个定义列表,另一个定义列表中的项目.当我运行这个时,我只获得包含引用它们的项目的列表.我真的需要获得列表中所有行的结果以及items表中引用每个列表的行数.
SELECT name, COUNT(items.listId) as itemCount
FROM lists
INNER JOIN items
ON lists._id = items.listId
GROUP BY items.listId
Run Code Online (Sandbox Code Playgroud)
任何帮助将非常感激.