用一天时间在macbook上安装好了AndroID Studio For Mac,注意dl.Google.com只支持电信网络下载,家里宽带如果是移动或者联通的,使用AS下载AndroID SDK和后面新建project下载gradle时网络都有问题(移动宽带无法直接下载,需要设置代理proxy)
今天用不到一天时间,为儿子开发的第一款AndroID App,用于九九乘法练习
package com.nathan.multiplicationtable;import androIDx.appcompat.app.AppCompatActivity;import androID.os.Bundle;import androID.vIEw.VIEw;import androID.vIEw.inputmethod.inputMethodManager;import androID.Widget.EditText;import androID.Widget.TextVIEw;import java.util.Random;public class MainActivity extends AppCompatActivity { int factor = 1, factorBase = 9; int facIEnd = 1, facIEndBase = 9; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); refreshQuestion(); } public voID calculateMT(VIEw vIEw){ EditText editTextAnswer = findVIEwByID(R.ID.editTextAnswer); TextVIEw textVIEwHints = findVIEwByID(R.ID.textVIEwHints); int answer = Integer.parseInt(String.valueOf(editTextAnswer.getText())); if(answer == factor * facIEnd) { textVIEwHints.setText(R.string.right); }else{ String strHints = String.format("%d x %d = %d", factor, facIEnd, factor*facIEnd); textVIEwHints.setText(this.getString(R.string.wrong)+"\n"+strHints); } } public voID nextQuestion(VIEw vIEw){ refreshQuestion(); } voID refreshQuestion(){ Random rand = new Random(); factor = rand.nextInt(factorBase) + 1; facIEnd = rand.nextInt(facIEndBase) + 1; // String question = Integer.toString(factor) + "x" + Integer.toString(facIEnd) + "="; TextVIEw textVIEwA = findVIEwByID(R.ID.textVIEwA); TextVIEw textVIEwB = findVIEwByID(R.ID.textVIEwB); EditText editTextAnswer = findVIEwByID(R.ID.editTextAnswer); TextVIEw textVIEwHints = findVIEwByID(R.ID.textVIEwHints); textVIEwA.setText(Integer.toString(factor)); textVIEwB.setText(Integer.toString(facIEnd)); editTextAnswer.setText(""); textVIEwHints.setText(""); }}
APP的截图如下:
总结以上是内存溢出为你收集整理的我为儿子开发的第一款Android App,用于九九乘法练习全部内容,希望文章能够帮你解决我为儿子开发的第一款Android App,用于九九乘法练习所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)