में getView() की एकाधिक कॉलिंग मेरी गतिविधि में ग्रिड व्यू शामिल है जिसमें 40+ तत्व हैं। गतिविधि शुरू करने के बाद उपयोगकर्ता अधिकतम 15 आइटम (3 पंक्तियां, प्रत्येक पंक्ति में 5 आइटम) देख सकता था। मैं getView में() शरीर लिखा हो रही दृश्य के LogCat नंबर करने के लिए पारित करने के लिए:ग्रिड व्यू
Log.i("getView()", "GETTING VIEW_POSITION[" + String.valueOf(position) + "]" + (convertView != null?convertView.toString():"null"));
मेरे ऐप शुरू करने के बाद मैं ऐसे लॉग मिलती है:
02-09 14:34:56.900: INFO/getView()(388): GETTING VIEW_POSITION[0]null
02-09 14:34:57.300: INFO/getView()(388): GETTING VIEW_POSITION[0][email protected]
02-09 14:34:57.300: INFO/getView()(388): GETTING VIEW_POSITION[1]null
02-09 14:34:57.400: INFO/getView()(388): GETTING VIEW_POSITION[2]null
02-09 14:34:57.510: INFO/getView()(388): GETTING VIEW_POSITION[3]null
02-09 14:34:57.620: INFO/getView()(388): GETTING VIEW_POSITION[4]null
02-09 14:34:57.720: INFO/getView()(388): GETTING VIEW_POSITION[5]null
02-09 14:34:57.840: INFO/getView()(388): GETTING VIEW_POSITION[6]null
02-09 14:34:57.930: INFO/getView()(388): GETTING VIEW_POSITION[7]null
02-09 14:34:58.273: DEBUG/dalvikvm(388): GC freed 3530 objects/322744 bytes in 270ms
02-09 14:34:58.280: INFO/getView()(388): GETTING VIEW_POSITION[8]null
02-09 14:34:58.300: INFO/getView()(388): GETTING VIEW_POSITION[9]null
02-09 14:34:58.320: INFO/getView()(388): GETTING VIEW_POSITION[10]null
02-09 14:34:58.340: INFO/getView()(388): GETTING VIEW_POSITION[11]null
02-09 14:34:58.360: INFO/getView()(388): GETTING VIEW_POSITION[12]null
02-09 14:34:58.380: INFO/getView()(388): GETTING VIEW_POSITION[13]null
02-09 14:34:58.400: INFO/getView()(388): GETTING VIEW_POSITION[14]null
02-09 14:34:59.220: INFO/getView()(388): GETTING VIEW_POSITION[0]null
02-09 14:34:59.490: INFO/getView()(388): GETTING VIEW_POSITION[0][email protected]
मैं भी लाल this मुद्दा इस तरह के बारे में पोस्ट । लेकिन भरने अभिभावक के रूप में सेट एक्सएमएल विवरण में मेरे GridView की ऊंचाई:
public class ImageAdapter extends BaseAdapter
{
private Activity activity;
private LayoutInflater inflater = null;
private ArrayList<Photo> photoes;
public ImageAdapter(Activity a, ArrayList<Photo> pictures)
{
photoes = pictures;
activity = a;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
Log.i("getView()", "GETTING VIEW_POSITION[" + String.valueOf(position) + "]" + (convertView != null?convertView.toString():"null"));
View mViewSlice = convertView;
if(convertView == null) {
mViewSlice = inflater.inflate(R.layout.photo_preview, null);
((TextView) mViewSlice.findViewById(R.id.name_of_photo)).setText(photoes.get(position).getName());
mViewSlice.setPadding(5, 5, 5, 5);
mViewSlice.setLayoutParams(new GridView.LayoutParams(-2, -2));
}
return mViewSlice;
}
@Override
public int getCount() {
return photoes.size();
}
@Override
public Object getItem(int position) {
return photoes.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
}
मुझे आशा है कि किसी को मेरी समस्या पर जवाब देंगे और मदद मिलेगी:
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="auto_fit"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp"
android:columnWidth="140dp"
android:gravity="center"
android:scrollbars="none"
/>
और अंत में सभी संदेहों को दूर करने के लिए, यहाँ मेरी एडाप्टर कोड है मुझे इसे हल करने के लिए।
आपके सुझावों की प्रतीक्षा कर रहा है। एलेक्स।
आपका प्रश्न क्या है? –