hey,
i am making an application in which i have to list the attendance of
people. I want to show name,total attendance, and present number in list of
every person.
i have made following files and tried. but i getting force close error.
please help
Thanks.
Gaurav
attendancelistadapter.java
package listAdapters;
import java.util.ArrayList;
import java.util.List;
import com.example.myandroid.Attendance;
import android.R;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class AttendanceListAdapter extends ArrayAdapter<Attendance_print> {
private int resource;
private LayoutInflater inflater;
private Context context;
private String[] values;
private ArrayList<Attendance_print> objects;
public AttendanceListAdapter(Context ct, int resourceId,
ArrayList<Attendance_print> objects) {
super(ct, resourceId, objects);
this.resource=resourceId;
context=ct;
this.objects=objects;
}
@Override
public View getView (int position, View convertView, ViewGroup parent)
{
inflater=(LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//creating a new view of my layout and inflate it in the row
convertView=(LinearLayout) inflater.inflate(resource,null);
/* extracting th attendance object to show
Attendance a=getItem(position);*/
Attendance_print a=null;
a= objects.get(position);
TextView name=(TextView)
convertView.findViewById(com.example.myandroid.R.id.attend_sub_name);
name.setText(a.getName());
TextView present=(TextView)
convertView.findViewById(com.example.myandroid.R.id.attend_present);
present.setText(a.getPresent());
TextView total=(TextView)
convertView.findViewById(com.example.myandroid.R.id.attend_total);
total.setText(a.getTotal());
return convertView;
}
}
attendance_print.java
package listAdapters;
public class Attendance_print {
int position;
String name;
String present;
String total;
public Attendance_print(String name,String total,String present)
{
super();
this.name=name;
this.total=total;
this.present=present;
}
public String getName()
{
return name;
}
public String getTotal()
{
return total;
}
public String getPresent()
{
return present;
}
}
attendance.java
package com.example.myandroid;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;
import utility.UserFunctions;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListView;
import listAdapters.*;
public class Attendance extends Activity {
private ListView listattendanceView;
private Context ctx;
private AttendanceListAdapter adapter;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String name=new String();
String total=new String();
String present=new String();
ArrayList listAttend=new ArrayList<Attendance_print>();
listAttend.add(new Attendance_print("Image Processing", "48", "40"));
listAttend.add(new Attendance_print("Image Processing", "50", "40"));
listattendanceView=(ListView) findViewById(R.id.attendance_list);
listattendanceView.setAdapter(new AttendanceListAdapter(ctx,
R.layout.attendlist, listAttend));
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en