一直对写点小程序感兴趣,投简历之余,尝试用Android写一个数独解码器,折腾了一个下午,发现只能解初级数独,传上来记录下,再继续完善。

整体思路是扫描每个方格可选的数字,确认唯一的数字填进去,再继续扫描,如此至填满所有的方格。局限性就是,当所有的空格都不存在唯一解,需要进行假设时,程序就解不出答案了。下个版本准备完善这个思路。

我设置了几个集合,分别是linesList、columnsList 、gridsList和resultList,用来保存每行,每列,每个大格(内含9小格)目前可选的数字,用resultList保存已经确认的数字。

运行图片如下:

代码如下:

package com.example.eric.sudoku2;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.util.Log;import android.view.View;import android.widget.Button;import android.widget.Toast;import java.util.ArrayList;import java.util.LinkedList;import java.util.List;public class MainActivity extends AppCompatActivity implements View.OnClickListener {    private Button bt1, bt2, bt3, bt4, bt5, bt6, bt7, bt8, bt9, bt10, bt11, bt12, bt13, bt14, bt15, bt16, bt17, bt18, bt19, bt20,            bt21, bt22, bt23, bt24, bt25, bt26, bt27, bt28, bt29, bt30, bt31, bt32, bt33, bt34, bt35, bt36, bt37, bt38, bt39, bt40,            bt41, bt42, bt43, bt44, bt45, bt46, bt47, bt48, bt49, bt50, bt51, bt52, bt53, bt54, bt55, bt56, bt57, bt58, bt59, bt60,            bt61, bt62, bt63, bt64, bt65, bt66, bt67, bt68, bt69, bt70, bt71, bt72, bt73, bt74, bt75, bt76, bt77, bt78, bt79, bt80, bt81;    private Button[] buttons = {bt1, bt2, bt3, bt4, bt5, bt6, bt7, bt8, bt9, bt10, bt11, bt12, bt13, bt14, bt15, bt16, bt17, bt18, bt19, bt20,            bt21, bt22, bt23, bt24, bt25, bt26, bt27, bt28, bt29, bt30, bt31, bt32, bt33, bt34, bt35, bt36, bt37, bt38, bt39, bt40,            bt41, bt42, bt43, bt44, bt45, bt46, bt47, bt48, bt49, bt50, bt51, bt52, bt53, bt54, bt55, bt56, bt57, bt58, bt59, bt60,            bt61, bt62, bt63, bt64, bt65, bt66, bt67, bt68, bt69, bt70, bt71, bt72, bt73, bt74, bt75, bt76, bt77, bt78, bt79, bt80, bt81};    private int[] ids = {R.id.a11, R.id.a12, R.id.a13, R.id.b14, R.id.b15, R.id.b16, R.id.c17, R.id.c18, R.id.c19,            R.id.a21, R.id.a22, R.id.a23, R.id.b24, R.id.b25, R.id.b26, R.id.c27, R.id.c28, R.id.c29,            R.id.a31, R.id.a32, R.id.a33, R.id.b34, R.id.b35, R.id.b36, R.id.c37, R.id.c38, R.id.c39,            R.id.d41, R.id.d42, R.id.d43, R.id.e44, R.id.e45, R.id.e46, R.id.f47, R.id.f48, R.id.f49,            R.id.d51, R.id.d52, R.id.d53, R.id.e54, R.id.e55, R.id.e56, R.id.f57, R.id.f58, R.id.f59,            R.id.d61, R.id.d62, R.id.d63, R.id.e64, R.id.e65, R.id.e66, R.id.f67, R.id.f68, R.id.f69,            R.id.g71, R.id.g72, R.id.g73, R.id.h74, R.id.h75, R.id.h76, R.id.i77, R.id.i78, R.id.i79,            R.id.g81, R.id.g82, R.id.g83, R.id.h84, R.id.h85, R.id.h86, R.id.i87, R.id.i88, R.id.i89,            R.id.g91, R.id.g92, R.id.g93, R.id.h94, R.id.h95, R.id.h96, R.id.i97, R.id.i98, R.id.i99};    private String[] stringIds = new String[81];    private Button getAnswer, reSet;    private Button n1, n2, n3, n4, n5, n6, n7, n8, n9, n10;    private Button[] numberBts = {n1, n2, n3, n4, n5, n6, n7, n8, n9, n10};    private int[] numberIds = {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, R.id.bt10};    private int currentPressed = -1;    private List<List<Integer>> linesList = new ArrayList<List<Integer>>(9);    private List<List<Integer>> columnsList = new ArrayList<List<Integer>>(9);    private List<List<Integer>> gridsList = new ArrayList<List<Integer>>(9);    private List<Integer> resultList = new ArrayList<Integer>(81);    private int complete=0;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        initView();        initData();    }    public void initData() {        initIdsArray();        initLists();    }    public void initView() {        for (int i = 0; i < buttons.length; i++) {            buttons[i] = (Button) findViewById(ids[i]);            buttons[i].setOnClickListener(this);            buttons[i].setTextColor(this.getResources().getColor(R.color.textcolor));        }        View.OnClickListener listener = new View.OnClickListener() { //数字按键1-9使用的按键监听            @Override            public void onClick(View v) {                int number = 0;                if (currentPressed == -1) {                    Toast.makeText(MainActivity.this, "请先选择要输入数字的方格", Toast.LENGTH_SHORT).show();                } else {                    for (int m = 0; m < numberIds.length; m++) {                        if (numberIds[m] == v.getId()) {                            number = m;                            break;                        }                    }                    if (number != 9) {                        String tempString = (String) buttons[currentPressed].getText();//获取该按键当前的文本                        if (!tempString.equals("")){                            int tempNumber = Integer.parseInt(tempString);                            addToLists(currentPressed, tempNumber);                            buttons[currentPressed].setText((number + 1) + "");                            deleteFromLists(currentPressed, number + 1);                        }else {                            buttons[currentPressed].setText((number + 1) + "");                            deleteFromLists(currentPressed, number + 1);                            complete++;                        }                    } else {                        String tempString = (String) buttons[currentPressed].getText();//获取该按键当前的文本                        if (!tempString.equals("")) { //如果当前按键的文本不为空,再执行删除操作                            int tempNumber = Integer.parseInt(tempString);                            buttons[currentPressed].setText("");//删除当前数字                            addToLists(currentPressed, tempNumber);                            complete--;                        }                    }                }            }        };        for (int k = 0; k < numberBts.length; k++) {            numberBts[k] = (Button) findViewById(numberIds[k]);            numberBts[k].setOnClickListener(listener);        }        getAnswer = (Button) findViewById(R.id.bt_getAnswer);        getAnswer.setOnClickListener(new View.OnClickListener() {//获得答案按键使用的监听            @Override            public void onClick(View v) {                scan();            }        });        reSet = (Button) findViewById(R.id.bt_reset);        reSet.setOnClickListener(new View.OnClickListener() {//重置按键使用的监听            @Override            public void onClick(View v) {               //还没来得及写            }        });    }    /** * 按键1-81使用的点击事件 * * @param v */    @Override    public void onClick(View v) {        int pressedBT = -1;        for (int i = 0; i < ids.length; i++) { //循环找到当前点击的是哪个按键,类似switch            if (v.getId() == ids[i]) {                pressedBT = i; //将当前点击的按键号码赋值给pressedBT                break;            }        }        if (pressedBT == currentPressed) { //如果点击的按键和当前已点击的按键相同            currentPressed = -1;//将当前点击按键标签设为-1,代表没有按键被点击            buttons[pressedBT].setBackgroundResource(R.drawable.style_button_notchoose);        } else {//如果点击的按键和当前已点击的按键不同            if (currentPressed == -1) {//如果当前没有其他按键被点击                currentPressed = pressedBT;//将当前点击按键标签的值设为pressedBT                buttons[currentPressed].setBackgroundResource(R.drawable.style_button_choose);            } else {//如果当前有其他按键被点击                buttons[currentPressed].setBackgroundResource(R.drawable.style_button_notchoose);                currentPressed = pressedBT;//将当前点击按键标签的值设为pressedBT                buttons[currentPressed].setBackgroundResource(R.drawable.style_button_choose);            }        }    }    public void reSet(){    }    /** * 逐个扫描每一个数字 */    public void scan() {        while (complete<81) {            for (int i = 0; i < resultList.size(); i++) {                if (resultList.get(i) == 0) {                    calc(i);                }            }        }    }    /** * 计算并判断是否是唯一选择,是的话则将答案添加到4大集合中 * @param id */    public void calc(int id) {        Integer[] location = getIntLocation(stringIds[id]);        List<Integer> gridAV = gridsList.get(location[0]);        List<Integer> lineAV = linesList.get(location[1]);        List<Integer> columnAV = columnsList.get(location[2]);        List<Integer> currentBTAV = new ArrayList<Integer>();        boolean lineHas = false;        boolean columnHas = false;        for (int i :gridAV) {            int temp=i;            for (int l : lineAV) {                if (l == temp) lineHas = true;            }            for (int c : columnAV) {                if (c == temp) columnHas = true;            }            if (lineHas == true && columnHas == true) currentBTAV.add(temp);            lineHas = false;            columnHas=false;        }        if (currentBTAV.size()==1){            resultList.set(id, currentBTAV.get(0));            buttons[id].setText("" + currentBTAV.get(0));            buttons[id].setTextColor(this.getResources().getColor(R.color.systemcolor));            complete++;            deleteFromLists(id,currentBTAV.get(0));        }    }    /** * 初始化各个集合 */    public void initLists() {        for (int i = 1; i <= 9; i++) {            List<Integer> tempList1 = new LinkedList<Integer>();            List<Integer> tempList2 = new LinkedList<Integer>();            List<Integer> tempList3 = new LinkedList<Integer>();            for (int k = 1; k <= 9; k++) {                tempList1.add(k);                tempList2.add(k);                tempList3.add(k);            }            linesList.add(tempList1);            columnsList.add(tempList2);            gridsList.add(tempList3);        }        for (int m = 1; m <= 81; m++) {//初始化每个button的可选数字            resultList.add(0);        }    }    /** * 根据传入的按键位置和数字删除3大可选数集合中的数字,并添加至结果集合 * * @param id * @param number */    public void deleteFromLists(int id, int number) {        String stringId = stringIds[id];        Integer[] location = getIntLocation(stringId);        gridsList.get(location[0]).remove((Integer) number);        linesList.get(location[1]).remove((Integer) number);        columnsList.get(location[2]).remove((Integer) number);        resultList.set(id, number);    }    /** * 根据传入的按键位置和数字向3大可选数集合中添加该数字,并从结果集合中删除 * * @param id * @param number */    public void addToLists(int id, int number) {        String stringId = stringIds[id];        Integer[] location = getIntLocation(stringId);        gridsList.get(location[0]).add(number);        linesList.get(location[1]).add(number);        columnsList.get(location[2]).add(number);        resultList.set(id, 0);    }    public Integer[] getIntLocation(String id) {        String grid = id.substring(0, 1);        int gridNumber = grid.charAt(0) - 97;        int line = Integer.parseInt(id.substring(1, 2))-1;        int column = Integer.parseInt(id.substring(2, 3))-1;        return new Integer[]{gridNumber, line, column};    }    /** * 为stringIds赋值,形成类似于a11...c19这样的id,与每个方格对应 * 将81个格分为9个区域,以e56为例,e代表所在方格,5代表行号,6代表列号 */    public void initIdsArray() {        int n = 0;        String grid = "a";        String[] line3 = {"a", "b", "c"};        String[] line6 = {"d", "e", "f"};        String[] line9 = {"g", "h", "i"};        for (int i = 1; i <= 9; i++) {            for (int k = 1; k <= 9; k++) {                String[] temp;                if (i < 4) {                    temp = line3;                } else if (i > 3 && i < 7) {                    temp = line6;                } else                    temp = line9;                String id = temp[(k - 1) / 3] + "" + i + "" + k;                stringIds[n++] = id;            }        }    }}

布局文件如下

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg_main" android:gravity="center" android:orientation="vertical" tools:context=".MainActivity">    <LinearLayout  android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5dp" android:background="#50fafafa" android:gravity="center" android:orientation="vertical" android:paddingLeft="2dp" android:paddingRight="2dp" android:paddingTop="4dp">        <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="2dp" android:layout_marginLeft="3dp" android:layout_marginRight="3dp" android:layout_weight="1" android:orientation="horizontal">            <Button  android:id="@+id/a11" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/a12" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/a13" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/b14" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/b15" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/b16" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/c17" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/c18" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/c19" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />        </LinearLayout>        <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="2dp" android:layout_marginLeft="3dp" android:layout_marginRight="3dp" android:layout_weight="1" android:orientation="horizontal">            <Button  android:id="@+id/a21" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/a22" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/a23" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/b24" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/b25" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/b26" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/c27" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/c28" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/c29" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />        </LinearLayout>        <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="4dp" android:layout_marginLeft="3dp" android:layout_marginRight="3dp" android:layout_weight="1" android:orientation="horizontal">            <Button  android:id="@+id/a31" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/a32" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/a33" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/b34" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/b35" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/b36" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/c37" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/c38" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/c39" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />        </LinearLayout>        <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="2dp" android:layout_marginLeft="3dp" android:layout_marginRight="3dp" android:layout_weight="1" android:orientation="horizontal">            <Button  android:id="@+id/d41" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/d42" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/d43" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/e44" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/e45" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/e46" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/f47" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/f48" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/f49" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />        </LinearLayout>        <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="2dp" android:layout_marginLeft="3dp" android:layout_marginRight="3dp" android:layout_weight="1" android:orientation="horizontal">            <Button  android:id="@+id/d51" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/d52" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/d53" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/e54" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/e55" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/e56" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/f57" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/f58" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/f59" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />        </LinearLayout>        <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="4dp" android:layout_marginLeft="3dp" android:layout_marginRight="3dp" android:layout_weight="1" android:orientation="horizontal">            <Button  android:id="@+id/d61" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/d62" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/d63" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/e64" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/e65" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/e66" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/f67" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/f68" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/f69" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />        </LinearLayout>        <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="2dp" android:layout_marginLeft="3dp" android:layout_marginRight="3dp" android:layout_weight="1" android:orientation="horizontal">            <Button  android:id="@+id/g71" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/g72" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/g73" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/h74" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/h75" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/h76" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/i77" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/i78" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/i79" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />        </LinearLayout>        <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="2dp" android:layout_marginLeft="3dp" android:layout_marginRight="3dp" android:layout_weight="1" android:orientation="horizontal">            <Button  android:id="@+id/g81" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/g82" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/g83" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/h84" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/h85" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/h86" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/i87" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/i88" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/i89" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />        </LinearLayout>        <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="2dp" android:layout_marginLeft="3dp" android:layout_marginRight="3dp" android:layout_weight="1" android:orientation="horizontal">            <Button  android:id="@+id/g91" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/g92" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/g93" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/h94" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/h95" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/h96" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="4dp" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/i97" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/i98" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />            <Button  android:id="@+id/i99" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/style_button_notchoose" android:textSize="25sp" android:textStyle="bold" />        </LinearLayout>        <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="10dp" android:layout_weight="3" android:orientation="vertical">            <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="1dp" android:layout_marginLeft="3dp" android:layout_marginRight="5dp" android:layout_weight="1" android:gravity="center" android:orientation="horizontal">                <Button  android:id="@+id/bt1" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="1" android:textSize="20sp" />                <Button  android:id="@+id/bt2" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="2" android:textSize="20sp" />                <Button  android:id="@+id/bt3" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="3" android:textSize="20sp" />                <Button  android:id="@+id/bt4" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="4" android:textSize="20sp" />                <Button  android:id="@+id/bt5" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="5" android:textSize="20sp" />                <Button  android:id="@+id/bt_getAnswer" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2" android:text="自动运算" android:textSize="15sp" android:layout_marginLeft="10dp"/>            </LinearLayout>            <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginLeft="3dp" android:layout_marginRight="3dp" android:layout_weight="1" android:gravity="center" android:orientation="horizontal">                <Button  android:id="@+id/bt6" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="6" android:textSize="20sp" />                <Button  android:id="@+id/bt7" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="7" android:textSize="20sp" />                <Button  android:id="@+id/bt8" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="8" android:textSize="20sp" />                <Button  android:id="@+id/bt9" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="9" android:textSize="20sp" />                <Button  android:id="@+id/bt10" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="DEL" android:textSize="12sp" />                <Button  android:id="@+id/bt_reset" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2" android:layout_marginLeft="10dp" android:textSize="15sp" android:text="重 置" />            </LinearLayout>        </LinearLayout>    </LinearLayout></LinearLayout>

更多相关文章

  1. android 修改电量图标(改为数字图标)
  2. 新建Android(安卓)AVD,点击start、launch,出现进度条后无任何反应,
  3. Android中Tabhost既可以点击切换又可滑动切换不同Activity的View
  4. 关于监听Android的静音键以及音量按键
  5. 键盘按下和抬起事件(keydown,keyup)——原创
  6. [置顶] Android(安卓)popwindow和fragment结合 左侧弹出下拉菜单
  7. Android小部件布局大小和点击事件
  8. 基于WebRTC的Android数字楼宇对讲系统回声消除
  9. 【Xamarin.Android】探索android的底部导航视图

随机推荐

  1. Android中Calendar与Date的区别以及消除
  2. Android(安卓)中 如何利用am input 命令
  3. android 应用类APP开发小结——android G
  4. 移动开发工程师面试题集:Android & iOS
  5. Android屏幕的刷新机制
  6. 万能前端框架uni app初探01:搭建开发环境
  7. Android 在 Windows 上用 Nexus3 搭建 Ma
  8. Android使用recycleView组件
  9. Android中的上下文菜单Context Menu
  10. Android(安卓)即时通讯开发小结(一)