我在页面加载时有一个网格视图,它填充了它。当我单击它时,我有一个同步按钮,它应该重新生成网格视图。如何做到这一点。
我在用
ImageAdapter adapter = new ImageAdapter(MainActivity.this);
gridview.setAdapter(adapter);
代码详细
try {
if(stringArrayPdfUrlForLocalDB.length>0)
{
for(int i=0 ; i < stringArrayPdfUrlForLocalDB.length ; i++)
{
String fileName = getOnlyFileName(stringArrayPdfUrlForLocalDB[i]);
String imageName = getImageName(stringArrayPdfUrlForLocalDB[i]);
String BookId = stringArrayBookId[i];
//Toast.makeText(getApplicationContext(), "File Name: "+fileName+"\nBookId: "+BookId, Toast.LENGTH_LONG).show();
db.open();
long id = db.insertRecord(BookId, fileName + ".pdf", imageName);
db.close();
}
}
else
{
Toast.makeText(getApplicationContext(), "Not getting any book form server.", Toast.LENGTH_SHORT).show();
}
//populate grid view
ImageAdapter adapter = new ImageAdapter(MainActivity.this);
gridview.setAdapter(adapter);
} catch (Throwable e) {
Toast.makeText(getApplicationContext(), ""+e, Toast.LENGTH_SHORT).show();
}