• 纯属娱乐,对入门Android有一定的帮助


    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 + " " + "人品得分:" + rp);
    lastName = name;http://www.huiyi8.com/webyuanma/
    result.setText("请更换测试者! 测试者姓名:" + name + " "
    + "人品得分:" + 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);
    }
     
    }
  • 相关阅读:
    java获取包下被指定注解的类
    Only fullscreen activities can request orientation 解决方法
    android 编译时注解
    android AOP编程
    webView渲染富文本
    看美剧神器
    神奇图书馆主题曲 歌词
    工体东路没有人
    微信小程序如何快速开通流量主
    微信小程序入门教程
  • 原文地址:https://www.cnblogs.com/xkzy/p/3804330.html
Copyright © 2020-2023  润新知