Ben 2 sütuna ve sonsuz satır tablonun aşağısında bir yorum ile bir küçük resim yerleştirir basit bir ızgara düzeni kurmak çalışıyorumAndroid'de GridLayout'u kullanarak, nasıl ekleyebilirim ki her eklediğim öğe doğru şekilde (sınırsız sayı) yerleştirilir? Bir resim çekilir zaman
(aşağıdaki bkz resim) ızgara düzenine eklenir, ancak denediğim tüm parametreler ya 3. resimden sonra bana bir hata verir ya da sadece yanlış görüntüler.
{CODE}
kodumu bu bölümü sadece çekilen bir görüntüden büyüklüğü 400.400 ile bir küçük resim oluşturur ve ardından GridLayout parametreleriyle birlikte GridLayout görünümüne eklenir.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//setups
setResult(resultCode);
GridLayout templayout = (GridLayout) findViewById(R.id.pictureLayout);
int col = 2;
int row = 2;
templayout.setColumnCount(col);
templayout.setRowCount(row);
String path = tempPicture[4];
ImageView image = new ImageView(this);
Bitmap thumb = createThumbnailFromBitmap(path, 400, 400);
image.setImageBitmap(thumb);
image.setLayoutParams(new android.view.ViewGroup.LayoutParams(400,400));
GridLayout.Spec rowSpan = GridLayout.spec(GridLayout.UNDEFINED, 1);
GridLayout.Spec colSpan = GridLayout.spec(GridLayout.UNDEFINED, 2);
GridLayout.LayoutParams gridParam = new GridLayout.LayoutParams(rowSpan, colSpan);
templayout.addView(image, gridParam);
temp = Integer.valueOf(tempPicture[0]);
image.setId(temp);
image.setTransitionName(path);
image.setOnClickListener(ClickPic(image));
addToTempList(tempPicture);
//This creates a edit text just below the newly created thumbnail
createEditableComment(tempPicture[0], templayout);
}
createComment yöntemi, sadece burada sadece neden benim xml var (bazen aşağıda)
void createEditableComment(String picId, GridLayout belowpic){
EditText comment = new EditText(this);
comment.setTextSize(20);
comment.setId(Integer.valueOf(picId));
comment.setLayoutParams(new android.view.ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
pictureComments.add(comment);
belowpic.addView(comment);
}
oluşturulmasından sonra küçük resmin altında ekleniyor. Şerefe
<GridLayout
android:orientation="vertical"
android:id="@+id/pictureLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:columnCount="2">
</GridLayout>
Sen quesition belli değil deneyin. –