0
我有兩個活動。提交數據和顯示提交數據的數據。我能夠將圖像添加到第一個活動罰款,然後數據存儲在一個單獨的數據對象與一個稱爲「圖像」的ArrayList實例。如何在Android上動態查看圖像視圖到線性佈局andorid
我遇到的問題是,當試圖從圖像數組中檢索圖像並顯示它們會使應用程序崩潰。我試圖調試代碼和它完美,直到你到最後一行運行:
attachmentLayout.addView(image,imParams);
圖像被正確地存儲在單身,當你調試它,它表明,他們實際上是在那裏。
我試圖弄清楚自己,但我找不到它是什麼。我很新的android編程,所以幫助將不勝感激。我添加了我的代碼,試圖獲取下面的圖像。
if(values.getImage()!=null){
int count = images.size()-1;
for (int x=0;x<=count;x++){
//declare attachments and get image from arraylist<ImageView>
LinearLayout attachmentLayout = (LinearLayout) findViewById(R.id.attachments);
ImageView image;
image = images.get(x);
//set parameters
LinearLayout.LayoutParams imParams =
new LinearLayout.LayoutParams(90,270);
image.setBottom(attachmentLayout.getBottom());
image.setVisibility(View.VISIBLE);
image.isShown();
//add to linear layout
attachmentLayout.addView(image,imParams);
}
}
編輯: 這是logcat的我得到,當應用程序重新啓動後崩潰。我不認爲這有幫助。
08-24 12:34:18.522 4782-4820/com.example.jules_gribble.test I/Adreno﹕ QUALCOMM build : 065751b,
Build Date : 04/15/15
OpenGL ES Shader Compiler Version: E031.25.03.07
Local Branch :
Remote Branch : quic/LA.BF64.1.2.1_rb2.9
Remote Branch : NONE
Reconstruct Branch : AU_LINUX_ANDROID_LA.BF64.1.2.1_RB2.05.01.00.081.016 + 065751b + NOTHING
顯示你的logcat錯誤 – Rajesh
沒有給出錯誤。它只是重新啓動應用程序 – jag
爲什麼你的'count = images.size() - 1'?只需在您的for循環中使用images.size –