我試圖通過Java,Eclipse開發Android應用程序。我想使用這個example。Android編程錯誤
我的活動:
package grid.View;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
public class ImageAdapter extends BaseAdapter {
private Context mContext;
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return mThumbIds.length;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
// create a new ImageView for each item referenced by the Adapter
public View getVieww(int position, View convertView, ViewGroup parent) {
ImageView imageVieww;
if (convertView == null) { // if it's not recycled, initialize some attributes
imageVieww = new ImageView(mContext);
imageVieww.setLayoutParams(new GridView.LayoutParams(85, 85));
imageVieww.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageVieww.setPadding(8, 8, 8, 8);
} else {
imageVieww = (ImageView) convertView;
}
imageVieww.setImageResource(mThumbIds[position]);
return imageVieww;
}
// references to our images
private Integer[] mThumbIds = {
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7,
R.drawable.sample_0, R.drawable.sample_1,
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7,
R.drawable.sample_0, R.drawable.sample_1,
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7
};
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
return null;
}
}
我有這樣的錯誤,所有這些 「樣本」:
sample_2不能得到解決或無法在現場
我是什麼應該做的? :S
謝謝!
它指向哪條線?你可能需要更具體一些,因爲它可能是很多事情。 – 2011-12-15 16:17:14