Hi, I am trying to render my listview containing names of doctors and few more details using a tablelayout component showing 4 textviews in each listview item. But I get an error while I am doing this..PLEASE HELP! I have a project deadline tomorrow.
When I debug by code, the control goes till IconicAdapter() constructer, from there it comes back to setListAdapter() in the onCreate and returns an error.
Any help is GREATLY Appreciated...thanks a ton in advance!
public class DetailedDoctor extends ListActivity
protected static ArrayList<Message> selectdrs;
protected Message msg[];
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
selectdrs = MessageList.selectmsgs;
setListAdapter(new IconicAdapter(this));
//setListAdapter(new IconicAdapter(this));
//selection=(TextView)findViewById(R.id.selection);
}
public void onListItemClick(ListView parent, View v,
int position, long id) {
// selection.setText(items[position]);
}
private class IconicAdapter extends ArrayAdapter<Message> {
Context context;
public IconicAdapter(Context context) {
super(context, R.layout.selectdr, selectdrs);
this.context=context;
}
public View getView(int position, View convertView,
ViewGroup parent) {
View row=convertView;
if (row==null) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row=vi.inflate(R.layout.row, null);
}
Message msg = selectdrs.get(position);
if (msg != null) {
TextView drn = (TextView) row.findViewById(R.id.drname);
TextView deg = (TextView) row.findViewById(R.id.degree);
TextView ofc = (TextView) row.findViewById(R.id.loc);
TextView rat = (TextView) row.findViewById(R.id.rating);
if (drn != null) {
drn.setText(msg.getTitle()); }
if(deg != null){
drn.setText(msg.getGenre());
}
if(ofc != null){
ofc.setText(msg.getGenre());
}
if(rat != null){
rat.setText(msg.getTitle());
}
}
return(row);
}
} }