【发布时间】:2016-08-22 10:15:31
【问题描述】:
tics 有 3 个项目。以下代码创建了 3 个工单项目,但始终设置第一个工单的 TextViews 的文本。
public void onSuccess(int i, Header[] headers, byte[] bytes) {
progress.dismiss();
String response = new String(bytes);
try{
JSONObject obj = new JSONObject(response);
JSONArray tics = obj.getJSONArray("tickets");
LinearLayout p = (LinearLayout)findViewById(R.id.tickets);
for(int j = 0;j<tics.length();j++){
LinearLayout t =(LinearLayout) getLayoutInflater().inflate(R.layout.ticket_row, p);
TextView topic = (TextView)t.findViewWithTag("topic");
TextView section = (TextView)t.findViewWithTag("section");
TextView datetime = (TextView)t.findViewWithTag("datetime");
JSONObject item = tics.getJSONObject(j);
Toast.makeText(getApplicationContext(),item.getString("Caption") ,Toast.LENGTH_LONG).show();
topic.setText(item.getString("Caption"));
datetime.setText(item.getString("DateString"));
section.setText(item.getString("Section"));
}
}catch (Exception e){}
}
在以下代码中:
LinearLayout t =(LinearLayout) getLayoutInflater().inflate(R.layout.ticket_row, p);
t不应该是膨胀的View吗?
【问题讨论】:
标签: java android android-studio layout-inflater