public class ListAdaptere extends BaseAdapter {
private Context activity;
private List<String> Beans;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader;
public String ListBn;
public ListAdaptere(Activity a,
List<String>Beans) {
activity = a;
this.Beans=Beans;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader=new ImageLoader(activity.getApplicationContext());
}
public int getCount() {
return Beans.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup
parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.list_row, null);
TextView Name = (TextView)vi.findViewById(R.id.Name); // title
TextView time = (TextView)vi.findViewById(R.id.marks);
TextView marks = (TextView)vi.findViewById(R.id.time);
//HashMap<String, String> song = new
HashMap<String, String>();
ListBn = Beans.get(position);
JSONObject Anssht;
try {
Anssht = new JSONObject(ListBn);
JSONObject Detail =
Anssht.getJSONObject("QuestionPaper");
String Name = Detail.getString("QuestionPaperName");
String TotalMrk = Detail.getString("TotalMarks");
String TotalTime = Detail.getString("TotalTime");
Name.setText(
Name.toString());
time.setText("Total Time: "+TotalTime.toString());
marks.setText( "Total Marks: "+TotalMrk.toString());
} catch (JSONException e) {
e.printStackTrace();
}
return vi;
}
}
}
==========================================================================
How To Use it From Activity Class
==========================================================================
How To Use it From Activity Class
adapter = new PaperListAdapter(this, QuestionPaperListBeans);
list.setAdapter(adapter);
No comments:
Post a Comment