0

以下に示すように、印刷用のコードを使用しました

btn_print.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            Thread t = new Thread() {
                public void run() {
                    try {
                        OutputStream os = mBluetoothSocket
                                .getOutputStream();
                        String BILL ="\n"+ oEditText.getText().toString();


                        os.write(BILL.getBytes());

                        Spanned ni = Html.fromHtml("<html><body>You scored <b>192</b> points.</body</html>");
                        System.out.println("*******ni****"+ni);

                        os.write(ni.toString().getBytes());


                        // This is printer specific code you can comment
                        // ==== > Start

                        // Setting height
                        int gs = 29;
                        os.write(intToByteArray(gs));
                        int h = 104;
                        os.write(intToByteArray(h));
                        int n = 162;
                        os.write(intToByteArray(n));

                        // Setting Width
                        int gs_width = 29;
                        os.write(intToByteArray(gs_width));
                        int w = 119;
                        os.write(intToByteArray(w));
                        int n_width = 2;
                        os.write(intToByteArray(n_width));

                        // Print BarCode
                        int gs1 = 29;
                        os.write(intToByteArray(gs1));
                        int k = 107;
                        os.write(intToByteArray(k));
                        int m = 73;
                        os.write(intToByteArray(m));

                        String barCodeVal = "ASDFC028060000005";// "HELLO12345678912345012";
                        System.out.println("Barcode Length : "
                                + barCodeVal.length());
                        int n1 = barCodeVal.length();
                        os.write(intToByteArray(n1));

                        for (int i = 0; i < barCodeVal.length(); i++) {
                            os.write((barCodeVal.charAt(i) + "").getBytes());
                        }
                        // printer specific code you can comment ==== > End
                    } catch (Exception e) {
                        Log.e("Main", "Exe ", e);
                    }
                }
            };
            t.start();
        }
    });

そして、私は次のように出力を得ました

192 ポイントを獲得しました

私が望む正しい出力は

192ポイントを獲得しました

つまり、192は太字にする必要があります.Any one help me to solve this issue

4

1 に答える 1

0

この行を変更してください:

Spanned ni = Html.fromHtml("<html><body>You scored <b>192</b> points.</body</html>");

Spanned ni = Html.fromHtml("You scored <b>192</b> points.");

なぜ内部<html>に ,<body>タグを提供しているのだろうかHtml.fromHtml

于 2013-09-20T12:20:06.163 に答える