我在导航抽屉中使用可扩展的列表视图.现在,此列表中的项目将从Web服务中获取 - 与子项一起提取.
根据登录类型,一些用户只能看到导航抽屉的一部分.所以我有一些项目有0个孩子,我需要检测这种情况,以便我可以重定向标题点击到另一个页面.
这是我的场景:
我想在单击标题时获取组中的子项数.这甚至可能吗?
到目前为止,我已经尝试过这个,但结果不合适:
@Override
public void onDrawerHeaderSelected(ExpandableListView parent, View v, int groupPosition, long id) {
switch (groupPosition) {
case 1:
if (parent.getChildCount() == 0)
displayFragment(groupPosition);
break;
case 2:
if (parent.getChildCount() == 0)
displayFragment(groupPosition);
break;
default:
displayFragment(groupPosition);
}
}
Run Code Online (Sandbox Code Playgroud)
parent.getChildCount() 似乎给我一个可见孩子的总数.
我试图更新一行数据库的内容这里是我的查询:
public void updateAdhoc(String value1, String value2, String value3,String CONTACT_ID){
int id = Integer.valueOf(CONTACT_ID);
String update = "UPDATE Adhoc SET Name = " + "'"+value1+"'" +","+
"DOB = " + "'"+value2+"'" +","+
"ImageData = " + "'"+value3+"'" +","+
"where " +adhocIdPrimary +"= " +id+";";
mDb.execSQL(update);
}
Run Code Online (Sandbox Code Playgroud)
代码在where子句中失败.以下是我的表创建字符串:
private static final String DATABASE_CREATE3 = "create table Adhoc (_id integer primary key autoincrement, "
+"DOB text, " +
"Name text not null, " +
"ImageData text);";
static final String DATABASE_TABLE3 = "Adhoc"; …Run Code Online (Sandbox Code Playgroud) 我收到以下内容作为Stringwebserveice 的回复:
[
[
{
"dgtype": "adhoc",
"subtypename": "Person",
"subtypedesc": "null",
"summary": "Junaid (Self)",
"subtype": "person",
"birthdate": "1995-1-23 ",
"name": "Junaid (Self)"
},
{
"dgtype": "adhoc",
"subtypename": "Job",
"subtypedesc": "null",
"summary": "Exa",
"subtype": "person",
"birthdate": "2010-01-30",
"name": "Junaid (Self)"
}
]
]
Run Code Online (Sandbox Code Playgroud)
在Java中,我尝试执行以下操作:
JSONArray jArray = new JSONArray(result);
System.out.println("Response: "+jArray);
for(int i = 0; i<= jArray.length(); i++){
try {
JSONObject oneObject = jArray.getJSONObject(i);
String dgtype = oneObject.getString("dgtype");
String subtypename = oneObject.getString("subtypename");
String subtypedesc = oneObject.getString("subtypedesc");
String summary = …Run Code Online (Sandbox Code Playgroud) 我有一个有数十亿条记录的ArrayList,我遍历每条记录并将其发布到服务器.在每次迭代中调用如下方法:
public void sendNotification(String url, String accountId, String accountPwd, String jsonPayLoad,
int maxConnections) {
notificationService = Executors.newFixedThreadPool(maxConnections);
notificationService.submit(new SendPushNotification(url, accountId, accountPwd, jsonPayLoad));
notificationService.shutdown();
}
Run Code Online (Sandbox Code Playgroud)
我的SendPushNotification类如下:
public class SendPushNotification implements Runnable {
String url;
String accountId;
String accountPwd;
String jsonPayLoad;
public SendPushNotification(String url, String accountId, String accountPwd, String jsonPayLoad) {
this.url = url;
this.accountId = accountId;
this.accountPwd = accountPwd;
this.jsonPayLoad = jsonPayLoad;
}
public void run() {
HttpsURLConnection conn = null;
try {
StringBuffer response;
URL url1 = new URL(url);
conn …Run Code Online (Sandbox Code Playgroud) 请考虑我对iOS非常新,虽然我能熟练使用Android,但我需要一个iOS项目,我们正在外包并提供图形,实际上我们正在将这个应用程序从iOS6迁移到iOS7,以便它适用于所有iPhone版本.理想情况下,图形的大小应该是多少?我偶然发现了这里,但发现它令人困惑,因为列表似乎只考虑图标,或者我可能无法浏览信息.任何人都可以帮助我使用表格格式的图像与每个iOS版本的大小.或任何链接甚至提示?