public void onCreate(Bundle icicle) {
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.transparentpanel);
id_pubblicazione_md5 = getIntent();
id_pubb_md5 = id_pubblicazione_md5.getStringExtra("id_md5");
elenco_id_pagine = id_pubblicazione_md5.getIntegerArrayListExtra("elenco_id_pagine");
g = (Gallery) findViewById(R.id.sfogliabile);
LoadingSfogliabile ldsf = new LoadingSfogliabile();
ldsf.execute();
}
public class LoadingSfogliabile extends AsyncTask<Bitmap, Bitmap, Bitmap>{
@Override
protected void onPostExecute(final Bitmap b) {
System.out.println("onPostExecute");
g.setAdapter(new BaseAdapter() {
public View getView(int position, View convertView, ViewGroup parent) {
ImageView i = new ImageView(getBaseContext());
i.setImageBitmap(b);
i.setScaleType(ImageView.ScaleType.FIT_CENTER);
i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
return i;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
public int getCount() {
// TODO Auto-generated method stub
return 0;
}
});
}
@Override
protected Bitmap doInBackground(Bitmap... params) {
System.out.println(params.length);
params = setSfogliabile();
System.out.println(setSfogliabile().length);
System.out.println(params.length);
return params[0];
}
}
public Bitmap[] setSfogliabile() {
Bitmap[] pagine = new Bitmap[elenco_id_pagine.size()];
/*************************************** FILE SYSTEM **************************************/
dir_pag = new File(ConfigApp.absolutePathPubb+id_pubb_md5, "pagine");
dir_pag.mkdirs();
dir_thumb = new File(ConfigApp.absolutePathPubb+id_pubb_md5, "thumb");
dir_thumb.mkdirs();
for(int y = 0; y < elenco_id_pagine.size(); y++) {
pagg = new File(dir_pag, Integer.toString(y+1));
pagg.mkdirs();
id_elemento = new File(pagg, (elenco_id_pagine.get(y)).toString());
id_elemento.mkdirs();
jpg_pagina = new File(id_elemento, ((elenco_id_pagine.get(y)).toString())+".jpg");
try {
/************************** SALVATAGGIO DELLE IMMAGINI IN LOCALE **************************/
String pagina = ConfigApp.urlPubbDir+id_pubb_md5+"/pagine/"+Integer.toString(y+1)+"/"+((elenco_id_pagine.get(y)).toString())+"/"+((elenco_id_pagine.get(y)).toString())+".jpg";
FileOutputStream fos = new FileOutputStream(jpg_pagina.getAbsolutePath());
pagine[y] = imd.downloadBitmap(pagina);
pagine[y].compress(CompressFormat.JPEG, 90, fos);
/******************************************************************************************/
} catch (IOException e) {
e.printStackTrace();
}
}
/************************************* FINE FILE SYSTEM ***********************************/
return pagine;
}`
怎么了?!?!?!
我不明白是什么问题!!
答案 0 :(得分:0)
我可以看到两个问题:
1)您的BaseAdapter子类为其getCount方法返回0的计数。这意味着GalleryView认为没有什么可以显示。
2)在较大的注释中,您的匿名BaseAdapter子类没有数据源。图库旨在显示滚动的项目条带,因此它希望您的适配器具有要显示的项目集合。您应该考虑执行以下操作之一: