I json Daten in listview.The json Array zeigen wollen, ist in console.but gezeigt, ich bin nicht in der Lage den Adapter Wert in listview.It gesetzt immer null Wert zurück .Wie Wert in Listenansicht erhalten in android
final ListView category_listview = (ListView)findViewById(R.id.category_dashboard_list);
category_detail = new Category_Dashboard_Adapter(getApplicationContext(), R.layout.category_row_list, cate_list);
category_listview.setAdapter(category_detail);
try {
jsono = new JSONObject(jsonvalue);
jarray = jsono.getJSONArray("jsonvalue");
for (int i = 0; i < jarray.length(); i++) {
JSONObject object = jarray.getJSONObject(i);
try
{
// object = jarray.getJSONObject(i);
Category_Detail_Model category_obj = new Category_Detail_Model();
category_obj.setCategory_Title(object.getString("bookmark_title"));
category_obj.setCategory_Description(object.getString("bookmark_title"));
category_obj.setCategory_Url(object.getString("bookmark_website"));
category_obj.setImage(object.getString("bookmark_preview_image"));
cate_list.add(category_obj);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
catch (JSONException e)
{
e.printStackTrace();
}
Hier category_listview.setAdapter (category_detail); NULL-Wert geben.
Hier Modelldatei ist
public class Category_Detail_Model{
private String category_title;
private String category_description;
private String category_url;
private String category_image;
public Category_Detail_Model() {
// TODO Auto-generated constructor stub
}
public Category_Detail_Model(String category_title, String category_description, String category_url, String category_image) {
super();
this.category_title = category_title;
this.category_description = category_description;
this.category_url =category_url;
this.category_image = category_image;
}
public String getCategory_Title() {
return category_title;
}
public void setCategory_Title(String category_title) {
this.category_title = category_title;
}
public String getCategory_Description() {
return category_description;
}
public void setCategory_Description(String category_description) {
this.category_description = category_description;
}
public String getCategory_Url() {
return category_url;
}
public void setCategory_Url(String category_url) {
this.category_url = category_url;
}
public String getCategory_Image() {
return category_image;
}
public void setImage(String category_image) {
this.category_image = category_image;
}
}
Und hier ist Adapter Klassencode
public class Category_Dashboard_Adapter extends ArrayAdapter<Category_Detail_Model> {
ArrayList<Category_Detail_Model> category_detail_list;
LayoutInflater vi;
int Resource;
ViewHolder holder;
Typeface font1 = Typeface.createFromAsset(getContext().getAssets(), "fonts/cabin.regular.ttf");
public Category_Dashboard_Adapter(Context context1, int resource1, ArrayList<Category_Detail_Model> objects1) {
super(context1, resource1, objects1);
vi = (LayoutInflater) context1
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Resource = resource1;
category_detail_list = objects1;
}
public View getView(int position1, View convertView1, ViewGroup parent1)
{
// convert view = design
View v = convertView1;
if (v == null) {
holder = new ViewHolder();
v = vi.inflate(Resource, null);
holder.category_imageview = (ImageView) v.findViewById(R.id.category_details_ivImage);
holder.category_title_holder = (TextView) v.findViewById(R.id.category_detail_title_view);
holder.category_desc_holder = (TextView) v.findViewById(R.id.category_detail_desc_view);
holder.category_url_holder = (TextView) v.findViewById(R.id.category_detail_url_view);
holder.category_title_holder.setTypeface(font1); holder.category_title_holder.setTextSize(16.0f);
holder.category_desc_holder.setTypeface(font1); holder.category_desc_holder.setTextSize(14.0f);
holder.category_url_holder.setTypeface(font1); holder.category_url_holder.setTextSize(10.0f);
// holder.txtCategory.setTypeface(font1); holder.txtCategory.setTextSize(10.0f);
v.setTag(holder);
} else {
holder = (ViewHolder) v.getTag();
}
new CategoryDownloadImageTask(holder.category_imageview).execute(category_detail_list.get(position1).getCategory_Image());
holder.category_title_holder.setText(category_detail_list.get(position1).getCategory_Title());
holder.category_desc_holder.setText(category_detail_list.get(position1).getCategory_Description());
holder.category_url_holder.setText(category_detail_list.get(position1).getCategory_Url());
return v;
}
static class ViewHolder {
public ImageView category_imageview;
public TextView category_title_holder;
public TextView category_desc_holder;
public TextView category_url_holder;
}
}
Lieber haben Sie ein Objekt von Arraylist erstellen? –
sind die Daten im Adapter oder nicht – Rgv