public int getChildrenCount(int groupPosition) {
if(children == null){
new SalesRequest().execute(); // runs in other thread which
// initialises children with some value.
while(children == null){
// I'm doin this to avoid null pointer Exception.
// So it comes out of the loop only when childern
// gets initialised.
}
}
return children.length;
}
Run Code Online (Sandbox Code Playgroud)
但我对我处理这个问题的方式并不满意.有一个更好的方法吗?
我让Json返回如下:
[{"CreatedBy":"GIS_DB","CreatedDate":"3/8/2012 10:44:00 AM","Id":39,"ModifiedBy":"","ModifiedDate":"","名称":"CF-39","StatusId":1,"TrailCoordinates":[{"CreatedBy":"GIS_DB","CreatedDate":"3/8/2012 10:44:00 AM","Id": 1637年, "纬度":32.76004207, "经度": - 97.34006853, "ModifiedBy": "", "ModifiedDate": "", "SortOrder的":1, "TrailId":39},{ "CreatedBy": "GIS_DB" ,"CreatedDate":"3/8/2012 10:44:00 AM","Id":1638,"Latitude":32.76004333,"经度": - 97.34012121,"ModifiedBy":"","ModifiedDate":" ","SortOrder":2,"TrailId":39}]},{"CreatedBy":"GIS_DB","CreatedDate":"3/8/2012 10:44:00 AM","Id":40, "ModifiedBy": "", "ModifiedDate": "", "名称": "CF-40", "StatusId":1, "TrailCoordinates":[{ "CreatedBy": "GIS_DB", "CreatedDate":"3/8/2012 10:44:00 AM","Id":3755,"纬度":32.76034332,"经度": - 97.3402069,"ModifiedBy":"","ModifiedDate":"","SortOrder":1 ,"TrailId":40},{"CreatedBy":"GIS_DB","CreatedDate":"3/8/2012 10:44:00 AM","Id":3756,"纬度":32.76019181,"经度" :-97.3402448, "ModifiedBy": "", "ModifiedDate": "", "SortOrder的":2 "TrailId":40}]}]
这些是我的班级......
public class Trails
{
[MonoTouch.Foundation.Preserve]
public Trails(){ TrailCoord = new List<trailcoords>();}
[MonoTouch.Foundation.Preserve, JsonProperty("Name")]
public string TrailName { get; set; }
[MonoTouch.Foundation.Preserve, JsonProperty("StatusId")]
public int StatusId { get; …Run Code Online (Sandbox Code Playgroud) 我有这个代码:
System.err.print("number of terms = ");
System.out.println(allTerms.size());
System.err.print("number of documents = ");
System.out.print("number of documents = ");
Run Code Online (Sandbox Code Playgroud)
我认为结果应如下:
number of terms = 10
number of documents =1000
Run Code Online (Sandbox Code Playgroud)
但结果是
10
1000
number of terms = number of documents =
Run Code Online (Sandbox Code Playgroud)
为什么,以及如何解决它?
在Java中开发时,并行系统或分布式系统是否更适合网站爬虫和Web索引器?有哪些框架?
我不是很擅长正则表达式.我需要执行以下操作来验证用户输入的密码是否正确.
标准:
我有一个名为remote_execution.sh的shell脚本.是否有可能只是输入remote_execution任何文件夹并开始执行,就像gcc,vi或任何此类命令一样?
提前致谢.
我是unix的初学者,我刚陷入困境.我正在处理的bash应用程序非常简单,可以添加联系人,删除联系人(基于名字和姓氏).下面是我的代码的一部分,由于某种原因,grep在排除(> contacts_file)时显示剩余的联系人,但在包含(> contacts_file)时不保存到文件.它将'contacts_file'留空.我怎样才能解决这个问题?或者有更好的方法来搜索联系人文件中的联系人吗?contacts_file中的格式为:firstname lastname
echo "[Remove a contact]"
echo "First Name: "
read first0
echo "Last Name: "
read last0
grep -vw -e "$first0 $last0" contacts_file >contacts_file
Run Code Online (Sandbox Code Playgroud) 我正在使用CodeIgniter和Ajax JQuery构建一个不错的应用程序,它最终返回一个很好的JSON类似对象,通过以下方式看出成功函数console.log ():
var data2 = {"field":fieldname,
"pagetitle":userdata};
$.ajax({
type: "POST",
url: "getdata_ajax",
dataType: 'json',
data: data2,
success: function(data) {
console.log(data);
}
});
Run Code Online (Sandbox Code Playgroud)
成功函数的结果:

很长一段时间以来,我试图从该对象中获取一个值.我试过了
console.log (data.id) console.log (data[id]) 但没有任何效果.我敢肯定它只是一个愚蠢的事情.有帮助吗?
假设我在Scala中有一个字符串数组:
val strings = Array[String]("1", "2", "3", "4", "5", "6", "7")
Run Code Online (Sandbox Code Playgroud)
我需要的是创建一个新的数组,哪些元素将作为第一个数组的每三个(任意数量)后续元素的串联获得,这应该导致 ("123", "456", "7")
作为Scala的新手,我编写了以下代码,既不简洁也不有效:
var step = 3
val strings = Array[String]("1", "2", "3", "4", "5", "6", "7")
val newStrings = collection.mutable.ArrayBuffer.empty[String]
for (i <- 0 until strings.length by step) {
var elem = ""
for (k <- 0 until step if i + k < strings.length) {
elem += strings(i + k)
}
newStrings += elem
}
Run Code Online (Sandbox Code Playgroud)
Scala的做法是什么?