3g嵌入式短学期实习报告 - 图文(4)

2019-03-28 16:28

2.画廊

class ImageAdapter extends BaseAdapter{

private Context context; private int[] im;

public ImageAdapter(Context c,int[] im){ }

public int getCount() { }

public Object getItem(int position) { }

public long getItemId(int position) {

// TODO Auto-generated method stub // TODO Auto-generated method stub return im[position];

// TODO Auto-generated method stub return im.length; this.context = c; this.im = im;

}

return position;

public View getView(int position, View convertView, ViewGroup parent) {

} }

ImageView iv = new ImageView(context); iv.setImageResource(im[position]);

iv.setLayoutParams(new Gallery.LayoutParams(200,200)); iv.setScaleType(ImageView.ScaleType.FIT_XY); return iv;

3.谁是幸运儿

public class LuckyActivity extends Activity {

String[] names = { \许世伟\, \杜星星\, \韩坚\, \黄哲\, \何美笑\ };

int[] imgs = { R.drawable.a, R.drawable.b, R.drawable.c, R.drawable.d,

R.drawable.e };

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState); setContentView(R.layout.main);

final ImageView imgr = (ImageView) this.findViewById(R.id.imgr); final TextView tvr = (TextView) this.findViewById(R.id.txr); Button btr = (Button) this.findViewById(R.id.btl);

btr.setOnClickListener(new OnClickListener() { public void onClick(View v) { Random r = new Random();

int lucky = r.nextInt(names.length); tvr.setText(names[lucky]);

imgr.setImageResource(imgs[lucky]);

}

});

} }

4.计算器

public class CalculatorActivity extends Activity { String str1; String str2; int result; int result1; int result2; TextView tv; Button temp; int flag = 0;

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);

tv = (TextView) this.findViewById(R.id.tv);

int[] buttons = { R.id.bt0, R.id.bt1, R.id.bt2, R.id.bt3, R.id.bt4,

R.id.bt5, R.id.bt6, R.id.bt7, R.id.bt8, R.id.bt9 };

Button btc = (Button) this.findViewById(R.id.btc); Button btjia = (Button) this.findViewById(R.id.btjia); str1 = String.valueOf(tv.getText()); str2 = \;

Button btjian = (Button) this.findViewById(R.id.btjian); Button btchen = (Button) this.findViewById(R.id.btchen); Button btchu = (Button) this.findViewById(R.id.btchu); Button btdengyu = (Button) this.findViewById(R.id.btdengyu); btc.setOnClickListener(new OnClickListener() {

public void onClick(View arg0) { }

String str = \; tv.setText(str);

});

for (int i = 0; i < buttons.length; i++) { }

buttonListener(btjia, 1); buttonListener(btjian, 2); buttonListener(btchen, 3); buttonListener(btchu, 4);

btdengyu.setOnClickListener(new OnClickListener() {

public void onClick(View v) {

result2 = Integer.parseInt(str2); switch (flag) { case 1:

result = result1 + result2; break;

temp = (Button) findViewById(buttons[i]); temp.setOnClickListener(new OnClickListener() {

public void onClick(View v) { }

str2 = tv.getText().toString().trim();

str2 = str2 + String.valueOf(((Button) v).getText()); tv.setText(str2);

});

case 2:

result = result1 - result2;

break;

case 3: result = result1 * result2;

break;

case 4: result = result1 / result2; break;

}

String str = (result + \).trim(); tv.setText(str);

}

});

}

public void buttonListener(Button button, final int id) { button.setOnClickListener(new OnClickListener() { public void onClick(View v) { String str = tv.getText().toString().trim(); result1 = Integer.parseInt(str); tv.setText(\); flag = id;

}

});

}

}

5.坦克大战

public class HjgameActivity extends Activity { public void onCreate(Bundle savedInstanceState) {


3g嵌入式短学期实习报告 - 图文(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:九年级化学下册 第十单元 课题2 酸和碱的中和反应(第1课时)教

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: