私のアプリでURLから画像を読み込もうとすると、画像が1つだけ表示されますが、両方の画像が水平に表示されるようにするには...両方の画像が同時に表示されます。動的に画像ビューを投稿することができません
は、ここに私のmainactivityです:
package com.example.hp.gotcha;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TableLayout;
import android.widget.TableRow;
import com.squareup.picasso.Picasso;
public class MainActivity extends AppCompatActivity {
public String[] urls;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
urls = new String[]{"url1...","url2...",};
TableLayout table = (TableLayout) findViewById(R.id.table);
TableRow tr = new TableRow(this);
TableRow.LayoutParams lay = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
ImageView image = new ImageView(this);
Picasso.with(this).load(urls[0]).into(image);
tr.addView(image, lay);
table.addView(tr);
TableRow tr1 = new TableRow(this);
TableRow.LayoutParams lay1 = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
ImageView image1 = new ImageView(this);
Picasso.with(this).load(urls[1]).into(image1);
tr.addView(image1, lay1);
table.addView(tr1);
}
}
ない水平に、あなたはあなたのTableLayoutに行を追加しているので、その表示は、垂直ではないでしょうか? –
まあまあ垂直でも... btは1つの画像しか画面に表示されません... btw返信ありがとう:) –
コードを実行しないと、何もしていないようです。 「1つの画像」と言うと、別のURLを使用していますか? –