1

I have a grid view on onCreate I am creating a grid view getting image url the from local database But when that activity is loading it showing a white screen.

How to remove that white screen I don't know where to move this gredview.A am attachig the full code please tell me what should I do.Try to click the sync button that sync button will first clear the local database then it get all xml value from server and put that into local database after that this activity will be restarted then this onCreat method will be called and blank white screen will be shown.

CODE URL http://www.fileconvoy.com/dfl.php?id=g2561f0a6e7dcc50b9992656609078e5c6d63c814c

My code follows

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    gridview = (GridView) findViewById(R.id.gridview);
    gridview.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View v, int position, long id) 
        {
            String pdfPath = Environment.getExternalStorageDirectory().toString() + "/ICA Faculty/";
            Toast.makeText(getApplicationContext(),pdfPath+((TextView) v.findViewById(R.id.hiddenPdfUrl)).getText(), Toast.LENGTH_SHORT).show();

            try {
                File file = new File(pdfPath+((TextView) v.findViewById(R.id.hiddenPdfUrl)).getText());
                Uri path = Uri.fromFile(file);
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setDataAndType(path, "application/pdf");
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
            } catch (Exception e) {
                Toast.makeText(getApplicationContext(),"Sorry no PDF reader found.", Toast.LENGTH_SHORT).show();
            }
        }
    });

    File folder = new File(Environment.getExternalStorageDirectory() + "/ICA Faculty");

    db.open();
    c = db.getAllRecords();

    //If data exist in local database AND "ICA Faculty" folder exist 
    //Getting the sd card file name from local database
    if (c.moveToFirst() && folder.exists() && folder.listFiles() != null)
    {
        //This array list will help to create image
        imgUrl = new ArrayList<String>();
        pdfUrl = new ArrayList<String>();
                do 

                    imgUrl.add(c.getString(3));
                    pdfUrl.add(c.getString(2));

                }  while (c.moveToNext());

                ImageAdapter adapter = new ImageAdapter(MainActivity.this);
                gridview.setAdapter(adapter);
    }
    else
    {
        Toast.makeText(getApplicationContext(), "You need to sync to create your library.", Toast.LENGTH_LONG).show();
    }
    db.close();
}
A J
  • 4,542
  • 5
  • 50
  • 80

1 Answers1

1

The GridView, as subclass of AdapterView, can use an empty view to show when there is no data by the setEmptyView() method.

For examples look at this question Correct use of setEmtpyView in AdapterView

Community
  • 1
  • 1
gipi
  • 2,432
  • 22
  • 25
  • if you post an update with what you have tried maybe someone can help you – gipi Apr 13 '13 at 13:09
  • this is project file http://www.fileconvoy.com/dfl.php?id=g2561f0a6e7dcc50b9992656609078e5c6d63c814c – A J Apr 16 '13 at 05:25