Displaying Images And Text In List View Using Json
I am fetching the images and data from mysql database from server using json array through url. i can able to do listview all images but i can't able to get text along with images.
Solution 1:
The ImageAdapter class should extend BaseAdapter. Refer http://pradeep-sharma.com/blog/android-custom-listview-baseadapter-tutorial/ .
Solution 2:
Use Adapter like this, Take all the text contents and Bitmaps into array before calling the Adapter
classNamesAdapterextendsBaseAdapter{
// @OverridepublicintgetCount() {
// TODO Auto-generated method stubreturn mImages.length;
}
// @Overridepublic Object getItem(int position) {
// TODO Auto-generated method stubreturnnull;
}
// @OverridepubliclonggetItemId(int position) {
// TODO Auto-generated method stubreturn0;
}
// @Overridepublic View getView(int pos, View convertView, ViewGroup parent) {
View row=getLayoutInflater().inflate(R.layout.imagetext,null);
TextView text=(TextView)row.findViewById(R.id.text);
ImageView image=(ImnageView)row.findViewById(R.id.image);
name.setText(text[pos]);
image.setImageBitmap(resizedbitmap[pos]);
return row;
}
}
Post a Comment for "Displaying Images And Text In List View Using Json"