mycustom adapter which extends from baseadapter but when i run my main java file it shows main activity no list view item
public class MyCustomadapter extends BaseAdapter{
private Context mycontext;
String[] mystringlist;
public MyCustomadapter(Context context,String[] strText) {
this.mycontext=context;
this.mystringlist = strText;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return mystringlist.length;
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
LayoutInflater inflater = (LayoutInflater) mycontext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
rowView = inflater.inflate(R.layout.each_row, parent,false);
TextView tv = (TextView) rowView.findViewById(R.id.rowtxt);
tv.setText(mystringlist[position]);
return rowView;
}
}
mycustom adapter which extends from baseadapter but when i run my main java file it shows main activity no list view item
problem:
return 0;
You are return 0 means there would be no list items to be displayed in your ListView
thus giving you 0 result.
You need to return the number of item in your array
or the length of it.
sample:
@Override
public int getCount() {
// TODO Auto-generated method stub
return mystringlist.length;
}