I am using custom adapter whose getView() method is not being called.I have a callback interface method which is called when async task is finished doing it's work.
public class Student extends Activity implements AsyncFinishInterface
{
private ListView list;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.student_screen);
list= (ListView) findViewById(R.id.listViewList);
new Aynctask().execute();
}
@Override
public void finish(String response, String method) throws Exception {
ArrayList<Friend> FriendList= new ArrayList<Friend>();
Friend friend;
JSONObject row;
JSONObject json= new JSONObject(response);
JSONArray jsonArray=json.getJSONArray("Friends");
int size=jsonArray.length();
Friend[] friendArray= new Friend[size];
for(int i=0 ; i<jsonArray.length(); i++)
{
friend = new Friend();
row= jsonArray.getJSONObject(i);
friend.setFirstName(row.getString("firstName"));
friend.setLastName(row.getString("lastName"));
friend.setEmail(row.getString("email"));
friendArray[i]=friend;
}
ContentAdapter contentAdapter= new ContentAdapter(this, R.layout.friend_detail, friendArray);
list.setAdapter(contentAdapter); //Till here it's working fine.
}
class ContentAdapter extends ArrayAdapter<Friend> {
Context context;
int layoutResourceId;
Friend data[] = null;
public ContentAdapter(Context context, int resource, Friend[] objects) {
super(context, resource, objects);
this.layoutResourceId = resource;
this.data = objects;
this.context = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
// ContentsHolder holder;
LayoutInflater inflater = ((Home_Screen) context)
.getLayoutInflater();
return row = inflater.inflate(layoutResourceId, parent, false);
}
@Override
public int getCount() {
int i= super.getCount();
return i;
}
}
Does any one have Idea what's going wrong here.
0 comments:
Post a Comment