该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
public class MainActivity extends Activity {
int[] draw={R.drawable.zya_a,R.drawable.zya_b,R.drawable.zya_c,
R.drawable.zya_d,R.drawable.zya_e,R.drawable.zyb_a,
R.drawable.zyb_b,R.drawable.zyb_c,R.drawable.zyb_d,
R.drawable.zyb_e}; 我在Button 中添加的图片
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GridView gv=(GridView) findViewById(R.id.main_grid);
GridAdapter grid=new GridAdapter(draw,this);
gv.setAdapter(grid);
}
刚学习 别讲深奥的
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View v=mylayout.inflate(R.layout.activity_grid, null);
Button ib=(Button) v.findViewById(R.id.grid_button);
ib.setBackgroundResource(drawables[position]);
tv=(TextView) v.findViewById(R.id.grid_text);
ib.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
tv.append("sss");
}
});
return v;
}