{"id":26751556,"url":"https://github.com/sayed3li97/simplecalculator-android","last_synced_at":"2025-03-28T12:18:37.064Z","repository":{"id":198676344,"uuid":"167852403","full_name":"sayed3li97/SimpleCalculator-Android","owner":"sayed3li97","description":"This project is part of Introduction to Android workshop. The exercise is a Simple Calculator app that \"Plus\", \"Minus\" and \"Multiplication\" two numbers. This exercise aims to introduce Java data types, casting and operations within the Android environment","archived":false,"fork":false,"pushed_at":"2021-12-10T10:58:49.000Z","size":130,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-10-06T11:41:45.992Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sayed3li97.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-01-27T20:01:16.000Z","updated_at":"2023-10-06T11:41:47.054Z","dependencies_parsed_at":null,"dependency_job_id":"0b112937-0741-4648-8fd6-78e22d1715fb","html_url":"https://github.com/sayed3li97/SimpleCalculator-Android","commit_stats":null,"previous_names":["sayed3li97/simplecalculator-android"],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayed3li97%2FSimpleCalculator-Android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayed3li97%2FSimpleCalculator-Android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayed3li97%2FSimpleCalculator-Android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayed3li97%2FSimpleCalculator-Android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sayed3li97","download_url":"https://codeload.github.com/sayed3li97/SimpleCalculator-Android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246026095,"owners_count":20711581,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-28T12:18:35.906Z","updated_at":"2025-03-28T12:18:36.782Z","avatar_url":"https://github.com/sayed3li97.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimpleCalculator\n\nThis project is part of the Introduction to Android workshop. The exercise is a Simple Calculator app with \"Plus,\" \"Minus,\" and \"Multiplication\" two numbers. This exercise introduces Java data types, casting, and operations within the Android environment.\n\n# Steps to re-create \n1. Create a new project in Android Studio (Choose the Empty Activity)\n2. Navigate to app/res/layout/activity_main.xml\n3. Open the Text view, and the replace the XML code with the below code \n```\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003c!-- The Constraint Layout was changed to Linuer Layout + Orientation was added in the attributes --\u003e\n\u003cLinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\"\n    tools:context=\".MainActivity\"\u003e\n\n    \u003cTextView\n        android:id=\"@+id/textView\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"Input 1\"\n        android:textColor=\"@android:color/black\"\n        android:textSize=\"18sp\" /\u003e\n\n    \u003cEditText\n        android:id=\"@+id/inputText1\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:ems=\"10\"\n        android:inputType=\"number\" /\u003e\n\n    \u003cTextView\n        android:id=\"@+id/textView2\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"Input 2\"\n        android:textColor=\"@android:color/black\"\n        android:textSize=\"18sp\" /\u003e\n\n    \u003cEditText\n        android:id=\"@+id/inputText2\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:ems=\"10\"\n        android:inputType=\"number\" /\u003e\n\n    \u003cTextView\n        android:id=\"@+id/results\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"Hello World!\"\n        android:textAlignment=\"center\"\n        android:textColor=\"@android:color/black\"\n        android:textSize=\"24sp\"\n        app:layout_constraintBottom_toBottomOf=\"parent\"\n        app:layout_constraintLeft_toLeftOf=\"parent\"\n        app:layout_constraintRight_toRightOf=\"parent\"\n        app:layout_constraintTop_toTopOf=\"parent\" /\u003e\n\n    \u003cLinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"horizontal\"\u003e\n\n        \u003cButton\n            android:id=\"@+id/buttonplus\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_weight=\"1\"\n            android:onClick=\"plus\"\n            android:text=\"+\"\n            android:textSize=\"30sp\" /\u003e\n\n        \u003cButton\n            android:id=\"@+id/button-\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_weight=\"1\"\n            android:onClick=\"minus\"\n            android:text=\"-\"\n            android:textSize=\"30sp\" /\u003e\n\n        \u003cButton\n            android:id=\"@+id/buttonx\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_weight=\"1\"\n            android:onClick=\"multi\"\n            android:text=\"x\"\n            android:textSize=\"30sp\" /\u003e\n    \u003c/LinearLayout\u003e\n\n\u003c/LinearLayout\u003e\n```\n4. Open the java file for the main activity by opening the MainActivity.java from the following path app/java/\"The first folder\"/MainActivity.java \n5. Replace the code in that file with the below code (\"Don't remove the first line starting with the package\")\n```\n\nimport android.support.v7.app.AppCompatActivity;\nimport android.os.Bundle;\nimport android.view.View;\nimport android.widget.EditText;\nimport android.widget.TextView;\n\npublic class MainActivity extends AppCompatActivity {\n\n    //Declare these Variable in this location to be accessed by all the functions in this class\n    private EditText Input1;\n    private EditText Input2;\n    private TextView Results;\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n\n        Input1 = (EditText) findViewById(R.id.inputText1);\n        Input2 = (EditText) findViewById(R.id.inputText2);\n        Results = (TextView) findViewById(R.id.results);\n\n    }\n\n    public void plus(View view){\n        int input1 = Integer.parseInt(Input1.getText().toString());\n        int input2 = Integer.parseInt(Input2.getText().toString());\n        String res = String.valueOf(input1 + input2);\n        Results.setText(res);\n    }\n\n    public void minus(View view){\n        int input1 = Integer.parseInt(Input1.getText().toString());\n        int input2 = Integer.parseInt(Input2.getText().toString());\n        String res = String.valueOf(input1 - input2);\n        Results.setText(res);\n    }\n\n    public void multi(View view){\n        int input1 = Integer.parseInt(Input1.getText().toString());\n        int input2 = Integer.parseInt(Input2.getText().toString());\n        String res = String.valueOf(input1 * input2);\n        Results.setText(res);\n    }\n}\n\n```\n\nThank you!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayed3li97%2Fsimplecalculator-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsayed3li97%2Fsimplecalculator-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayed3li97%2Fsimplecalculator-android/lists"}