DT @22.11.2015: Added new reportListAdapter #2
This commit is contained in:
@@ -1,7 +1,69 @@
|
|||||||
package org.deke.risk.riskahead.helper;
|
package org.deke.risk.riskahead.helper;
|
||||||
|
|
||||||
/**
|
import android.content.Context;
|
||||||
* Created by Dennis on 22.11.2015.
|
import android.graphics.Color;
|
||||||
*/
|
import android.graphics.Typeface;
|
||||||
public class ReportListAdapter {
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.deke.risk.riskahead.R;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ReportListAdapter extends BaseAdapter {
|
||||||
|
|
||||||
|
Context context;
|
||||||
|
List<JSONObject> data;
|
||||||
|
|
||||||
|
private static LayoutInflater inflater = null;
|
||||||
|
|
||||||
|
public ReportListAdapter(Context context, List<JSONObject> data) {
|
||||||
|
this.context = context;
|
||||||
|
this.data = data;
|
||||||
|
inflater = (LayoutInflater) context
|
||||||
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return data.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return data.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
View vi = convertView;
|
||||||
|
if (vi == null) vi = inflater.inflate(R.layout.activity_reportlist_lvrow, null);
|
||||||
|
|
||||||
|
TextView itemText = (TextView) vi.findViewById(R.id.txt_reportlist_lvrow_text);
|
||||||
|
TextView titleText = (TextView) vi.findViewById(R.id.txt_reportlist_lvrow_title);
|
||||||
|
TextView categoryText = (TextView) vi.findViewById(R.id.txt_reportlist_lvrow_category);
|
||||||
|
LinearLayout ll = (LinearLayout) vi.findViewById(R.id.lay_reportlist_color);
|
||||||
|
|
||||||
|
try {
|
||||||
|
titleText.setText(data.get(position).getString("created_at")+" : "+data.get(position).getString("text_short"));
|
||||||
|
itemText.setText(data.get(position).getString("text_long"));
|
||||||
|
categoryText.setText(data.get(position).getString("cat_name"));
|
||||||
|
titleText.setTypeface(null, Typeface.BOLD);
|
||||||
|
ll.setBackgroundColor(Color.parseColor("#" + data.get(position).getString("color")));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return vi;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user