Android and Its easy calculator...

Source: Internet
Author: User

Body

I wrote a lot of lab reports, but blog posts were written for the first time. There may be a lot of nonsense. I hope you will forgive me...

 

I was surprised and ashamed to know that I had not set up a proper environment at that time .. Android is always a drag-and-drop excuse for failing to find books in the library .. In fact, I just set up the environment on a plane to Shanghai. I am very pleased to see the interface popped up on the simulator, although the speed is extremely slow .. Because it is rare to find a boyfriend, I didn't have any plans to study. On the 8th, I came back to complete my study for a day. The books I bought online have not yet been sent! I borrowed some books from the club .. The uploaded video data is being resumed .. Okay .. I admit that this is an excuse for my laziness .. However, it is difficult for me to borrow one from Yujie (Yang Xiaoyu .. So today! After finishing the data structure experiment! I decided to start learning about Android! (I am an honest child .. To tell the truth, you need courage ..) The first time I spoke more nonsense, I thought it was an excuse for my laziness ~ Let's get down to the truth... Let's start with an interface .. I have to admit that it is really ugly .. I am ashamed to be a girl ..

 

First, the layout was determined. The calculator naturally thought of the layout of the table. But I always thought that the layout of the table must be standard for each column in each row. If there is a small number of rows, it will only be displayed on the left, for example, clear and hyphen are placed on the top of 7 and 8 .. So I thought about the standardized group of tables below, which have two linear la S .. In fact, I was inspired by the Panel in Java .. You can have a panel on the panel .. (Forgive the ignorance of a beginner ..) As for a limited reference book, I mean the content is too concise .. I didn't understand how to combine the layout .. Google it online .. I found an Android: layout_span (this is not prompted in the eclipse button tag! Strong protest !).. So it is easy to implement the interface that was just conceived at the beginning .. Edittext first, and then <tablerow> put one row at a time. Clear indicates layout_span = "3 .." -"The error was reported at the beginning, because the English version used should conflict with the logo. I just wanted to add an escape \ To Make It Chinese .. Oh, yes. stretchcolumns = "*" should be stretched. Otherwise, it would be ugly .. In addition, these la s are all written in Main. xml ..

 

The value of edittext is "0." At the beginning, but it is displayed on the left by default. It does not conform to the Conventions. Just add Android: gravity = "center_vertical | right .. I personally think Google is much better than books .. In the Java file, the private string TMP is constructed to change the edittext content. Each onclick operation appends the value of this button to TMP and display it in settext, clear is set to "0. ", TMP also needs to be cleared."-"means to use substring. It is Java and can be guessed ~ BUG: I added TMP = "" When I clicked "clear", but it was added to the original TMP when I clicked the button again .. It's inconvenient for me to have no lights. Let's talk about it tomorrow ~

 

The addition, subtraction, multiplication, division, is to convert string into numbers and then output them in onclick. The processing of each button is similar, and the code is very repetitive ..

 

In fact, I have not completed the compilation .. Bugs always exist .. As for the addition of sound, the version controller has not been able to see it. There are many things this week. I wanted to put this first, but it seems that everyone has handed in the trend of the times... So let's take a prototype...

 

The general feeling is that it is quite easy to get started with the Java Foundation. Today, I have a general idea about how Android development works .. I will certainly add more content to blog posts. There are still a lot of things to do. This is really hard to get .. Let's take a look .. PS: I hope my book will be sent to you soon. Please help me with this document ~~~~

/*************************************** **************************************** **********

Day 2

**************************************** **************************************** *********/

Today, I started to learn how to add voice and version controllers .. In addition, the calculator that is very watery is converted into a calculator that is relatively watery ..

Due to the rush to submit a blog post yesterday, there were a lot of bugs. For example, you could only calculate one type of computation, and the result would be incorrect when you calculate the other type. Because the calculation can only be performed when the operator and equal sign are clicked to obtain the value of the result, the last subtraction operation is ignored after the subtraction operation and the char (for switch) is declared) flag = ''; then, the flag value is set every time you click it to know what the previous operation was. I still don't know what's going on .. Calculating the number of decimal points is sometimes incorrect. I did not find the rule of errors and did not understand it .. We use the double type for addition and subtraction, 5-3.2 = 1.79999999999998, but 30-3.2 is equal to 26.8. I asked Ren Zhenyu to take out his mobile phone and open his own calculator (Android ).
2.1-12.43 = 12.4, so I am relieved .. I have output both the subtrahend and the subtrahend before computation, which are correct. Even if I forget it, the above results may appear. It is estimated that it is still about double precision ..

 

It's just a day before I add a sound! Mediaplayer is used in the book. I think it's all about playing music. I found soundpool on the Internet. I tried both of them, but I still can't! I first dragged the. Mid audio file to RES/raw, and then tried both methods to fail .. Sometimes force exit .. The content of the materials on the Internet is the same. There are only a few different versions that have not been understood yet .. No preparation for the English speech tomorrow morning .. Sound temporarily put...

And then the version controller .. Files on group sharing cannot be opened .. I found a good tutorial on the Internet ~ Remember to set it as a repository, and then there will be a check mark in the folder ~ However, it can be operated normally even if it is not set .. You can obtain online resources or clone them locally .. It can also be uploaded to the server. Just configure it .. But I have never tried to push things to each other .. Hurry to prepare speech to go... I knew that I did not select Advanced Oral English...

Later, after more than a year, the first experiment in the android class happened to be a calculator, and the program was pulled out again. It was really disgusting .. The code is restructured, fix the bug, the function is relatively simple, the reconstruction of the project is: http://download.csdn.net/detail/felicitia/5367521 do not go down the previous project .. Shame .. The new version has the following interface: tablelayout, which is very simple and suitable for beginners. If you have any bugs, please feel free to contact us ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.