这里是我的代码,用于显示用于在饼图中显示数据的文本标签现在我想要隐藏文本标签值,如果数据不是针对特定文本值,我怎么能在下面找到我的代码
final ArrayList<PieEntry> yEntrys = new ArrayList<>();
//List<String> entries = new ArrayList<>();
Toast.makeText(getContext(), "Toase"+response.toString(), Toast.LENGTH_SHORT).show();
Log.d("pieData",response.toString());
try {
JSONArray jsonarray = (JSONArray) response.get("piechartlist");
for (int i = 0; i < jsonarray.length(); i++) {
JSONObject jsonobject = jsonarray.getJSONObject(i);
String messageSent = jsonobject.getString("messageSent").trim();
String failed = jsonobject.getString("failed").trim();
String rejected = jsonobject.getString("rejected").trim();
String expired = jsonobject.getString("expired").trim();
String unDelivered = jsonobject.getString("unDelivered");
String delivered = jsonobject.getString("delivered");
String ndnc = jsonobject.getString("ndnc");
yEntrys.add(new PieEntry(Integer.valueOf(messageSent), "messageSent"));
yEntrys.add(new PieEntry(Integer.valueOf(failed), "failed"));
yEntrys.add(new PieEntry(Integer.valueOf(rejected), "rejected"));
yEntrys.add(new PieEntry(Integer.valueOf(expired), "expired"));
yEntrys.add(new PieEntry(Integer.valueOf(unDelivered), "unDelivered"));
yEntrys.add(new PieEntry(Integer.valueOf(delivered), "delivered"));
yEntrys.add(new PieEntry(Integer.valueOf(ndnc), "ndnc"));
}
} catch (JSONException e) {
e.printStackTrace();
}
答案 0 :(得分:1)
不要将条目添加到PieChart。
if (Integer.valueOf(messageSent) > 0)
{
yEntrys.add(new PieEntry(Integer.valueOf(messageSent), "messageSent"));
}
btw:您的JSON解析有点连线。我建议使用POJO和GSON来解析JSON字符串。