纯属娱乐,对入门Android有一定的帮助
2024-10-21 06:47:05
package android.m9;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class helloWorld extends Activity {
private TextView logo;
private EditText et;
private Button reset, submit;
private EditText result;
private String name;
private String lastName = "";
private int rp;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// /////////////////////////////////////////////
// logo set
logo = (TextView) findViewById(R.id.TextView_1);
logo.setText(R.string.logo);
// ////////////////////////////////////////////
// EditText set
et = (EditText) findViewById(R.id.EditText_1);
et.setText(R.string.inputTip);
// ////////////////////////////////////////////
// Button set:reset
reset = (Button) findViewById(R.id.Button_1);
reset.setText(R.string.reset);
reset.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
et.setText(R.string.inputTip);
result.setText("");
}
});
//Button set:reset
submit = (Button) findViewById(R.id.Burron_2);
submit.setText(R.string.submit);
submit.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
name = et.getText().toString();
if (!lastName.equals(name)) {
rp = (int) (Math.random() * 100);
result.setText("测试者姓名:" + name + "\n\n" + "人品得分:" + rp);
lastName = name;http://www.huiyi8.com/webyuanma/
} else {网站源码下载
result.setText("请更换测试者!\n\n测试者姓名:" + name + "\n\n"
+ "人品得分:" + rp);
}
}
});
// ////////////////////////////////////////////
// TextView set
result = (EditText) findViewById(R.id.EditText_2);
result.setEnabled(false);
result.setTextColor(android.graphics.Color.BLUE);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 1, 1, R.string.exit);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == 1) {
finish();
}
return super.onOptionsItemSelected(item);
}
}
最新文章
- [Cordova] Plugin里使用Android Library
- git 教程(3)--时光机穿梭
- AIM Tech Round 3 (Div. 2) A B C D
- 配置Tomcat 中文字符集问题
- GLSL实现Interactive Fluid 流体【转】
- UILabel 自适应大小
- php中var_export与var_dump的区别分析
- Elasticsearch学习1--head插件安装
- Spring Boot集成Jasypt安全框架
- 武汉科技大学ACM:1007: 陶陶摘苹果
- 【剑指offer】面试题28:字符串的排列
- python 性能优化
- Entity Framework基金会
- 算法模板——Dinic网络最大流 2
- 小强的Hadoop学习之路
- SQL模板资源管理器,你用了吗?
- PyCharm2019 激活码
- Mysql生产指定时间段随机日期函数
- 五、core开发
- node_01_自定义模块(先创建package.json)
热门文章
- Attempt to invoke virtual method 'void android.app.ActionBar.setTitle的解决方法
- android clipRect Op.xxx各个参数理解
- vue Syntax Error: Unexpected token {
- 手动安装pip
- vscode格式化代码无效--可能的解决方法
- 使用 sftp 向linux服务器传输文件
- 广告制胜无它,顺应人性尔——leo鉴书63
- mysql 查看当前连接数
- hdu3251 最小割
- 牛顿迭代法(Newton&;#39;s Method)