English 中文(简体)
如何在甲体内进行历史计算?
原标题:How do i make a history calculator in android?
  • 时间:2012-05-02 06:44:32
  •  标签:
  • android

I am making a calculator same as windows calculator. I am stuck at the history feature. which would be the best UI control to implement the history feature as seen in Windows Calculator? I also want onclick events on the history.

问题回答

我不敢肯定你如何计算,但你可以有这样的简单类别:

enum Operator {PLUS,MINUS,DIV,MULT};

class Calculation {
    float operand1,operand2;
    Operator operator;
    public Calculation(float op1,float op2,Operator operator){
        this.operand1=op1;
        this.operand1=op2;
        this.operator=operator;
    }
}

在进行计算时,就会产生此类物体,并添加到一名阿雷拉派教徒身上:

List<Calculation> history = new ArrayList<Calculation>();// history

history.add(new Calculation(5,5,Operator.PLUS));// add a new `Calculation` to our list

然后,根据您的《国际交易日志》,以<代码>history.get( Some_integer)查阅清单。

Could you just use a List containing a number of previously entered calculations? If you knew the maximum possible history size in advance, you could just stick with a normal array, but a List will give you more flexibility.

你们需要把所有业务和成果都储存在这里。 每当你开展一次行动时,每增加一次指数。 为了收回过去的作业,操纵指数,并且能够取得价值。 你们可以利用收集工具储存业务。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签