2010-10-01 44 views
1

我在我的android應用程序中查詢,從自定義表中拉出所有圖像路徑,並將它們顯示到一個畫廊。問題是我的數據庫我似乎無法得到一個字符串[]數據庫的一行。我可以很容易地得到結果列表陣列,但我需要在字符串或字符串數​​組中的圖像路徑。我希望能夠點擊多媒體資料中的圖像,並把它拉起來全屏幕能夠放大或刪除它等,這是基本的查詢我使用Android:光標結果爲字符串[]

public void listimages() { 

    SimpleCursorAdapter adapter; 

    String[] columns = {"Image", "ImageDate", "_id"}; 

    query = new TableImages(this); 

    queryString = query.getData("images", columns, null, null, null, null, "ImageDate", "DESC"); 

    int to[] = {R.id._id1, R.id._id2}; 
    adapter = new SimpleCursorAdapter(this, R.layout.imagelist, queryString, columns, to); 

    Gallery g = (Gallery) findViewById(R.id.gallery); 
    g.setAdapter(adapter); 
    g.setOnItemClickListener(this); 

    try { 
     query.destroy(); 
    } catch (Throwable e) { 
     e.printStackTrace(); 
    } 
} 

public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 
    Intent i = new Intent(ViewAllImages.this, ImageViewer.class); 
    Bundle b = new Bundle(); 
    //I want to be able to use this -> b.putString("image_path", Image); 
    b.putlong("id", id); 
    i.putExtras(b); 
    startActivity(i); 
} 

這通ID到我的下一個活動,下一個活動查詢拉取該圖像路徑的數據庫。我仍然需要使用listview來顯示圖像,這會導致應用程序在手機上因內存使用而崩潰(圖像太大)。

我可以壓縮圖像,但我需要的路徑作爲一個字符串,我不知道如何做到這一點,而不創建一個自定義的內容提供商或添加一個textview和使用gettext.toString和那就是getto。我的頭像我所做的所有閱讀和編碼一樣,因此而殺了我。我搜遍了谷歌和不同的論壇,但我有問題找到答案。

有沒有辦法使用現有的查詢並得到一個字符串或字符串數​​組作爲結果?

謝謝。

回答

0

我剛剛建立了一個自定義內容提供者。現在我在查詢中有更多的靈活性。