2011-11-29 22 views

回答

1

您創建一個自定義適配器使用您的圖庫查看,見Hello Gallery tutorial

在方法getView()你有兩種不同的方式來達到同樣的效果:

A.製作ImageView和TextView並設置圖像和文本:

ImageView iv = new ImageView(context); //and so on, remember to set the LayoutParams etc to fit your design. 

設置RelativeLayout並將ImageView和TextView添加到它

返回RelativeLayout。

B.聲明在XML佈局,用含有一個TextView和ImageView的

在getView一個RelativeLayout的,膨脹這樣的佈局,以及使用

inflatedLayout.findViewById(R.id.myTextView); //and so on 

設置文本和圖像,並且返回佈局。

+0

以及如何將此佈局用於圖庫項目? –

+0

看到我更新的答案,只問你是否需要更多的澄清 – Marmoy

+0

好的,謝謝你! 但是,如果我嘗試它的方式A,我如何返回佈局?因爲該功能需要一個視圖? Sry爲愚蠢的問題,但即時通訊相對新的Android :) –

相關問題