首页上一页 1 下一页尾页 1 条记录 1/1页
LinearLayoutImage已停止运行
发表在Android图书答疑
2014-05-20
是否精华
是
否
版块置顶:
是
否
package com.mingsoft;
import android.app.ActionBar.LayoutParams;
import android.app.Activity;
import android.os.Bundle;
import android.widget.*;
public class LinearLayoutImage1 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView img[]=new ImageView[4];
int imagePath[]=new int[]{R.drawable.img01,R.drawable.img02,R.drawable.img03,R.drawable.img04};
LinearLayout layout=(LinearLayout)findViewById(R.id.linearlayout);
for(int i=0;i<imagePath.length;i++)
{
img[i]=new ImageView(this);
img[i].setImageResource(imagePath[i]);
img[i].setPadding(5,5,5,5);
LayoutParams params=new LayoutParams(170,100);
img[i].setLayoutParams(params);
layout.addView(img[i]);
}
}
}
import android.app.ActionBar.LayoutParams;
import android.app.Activity;
import android.os.Bundle;
import android.widget.*;
public class LinearLayoutImage1 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView img[]=new ImageView[4];
int imagePath[]=new int[]{R.drawable.img01,R.drawable.img02,R.drawable.img03,R.drawable.img04};
LinearLayout layout=(LinearLayout)findViewById(R.id.linearlayout);
for(int i=0;i<imagePath.length;i++)
{
img[i]=new ImageView(this);
img[i].setImageResource(imagePath[i]);
img[i].setPadding(5,5,5,5);
LayoutParams params=new LayoutParams(170,100);
img[i].setLayoutParams(params);
layout.addView(img[i]);
}
}
}