Giter VIP home page Giter VIP logo

busaud's Projects

android.calculator icon android.calculator

package goldenapple.calculator; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.TextView; public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //bn = Button Number Button bn1 = (Button) findViewById(R.id.Bn1); Button bn2 = (Button) findViewById(R.id.Bn2); Button bn3 = (Button) findViewById(R.id.Bn3); Button bn4 = (Button) findViewById(R.id.Bn4); Button bn5 = (Button) findViewById(R.id.Bn5); Button bn6 = (Button) findViewById(R.id.Bn6); Button bn7 = (Button) findViewById(R.id.Bn7); Button bn8 = (Button) findViewById(R.id.Bn8); Button bn9 = (Button) findViewById(R.id.Bn9); Button bn0 = (Button) findViewById(R.id.Bn0); //ba = Button Action Button ba1 = (Button) findViewById(R.id.Ba1); Button ba2 = (Button) findViewById(R.id.Ba2); Button ba3 = (Button) findViewById(R.id.Ba3); Button ba4 = (Button) findViewById(R.id.Ba4); Button ba5 = (Button) findViewById(R.id.Ba5); Button bac = (Button) findViewById(R.id.Bac); final TextView tv1 = (TextView) findViewById (R.id.TV1); // مربع الأرقام المدخلة final TextView tv2 = (TextView) findViewById (R.id.TV2); // المربع اسفل الصفحة // وضعته فقط لاستطيع تكرار الأرقام في مربع الإدخال final TextView tv3 = (TextView) findViewById (R.id.TV3); // مربع الرقم المنتظر final TextView tv4 = (TextView) findViewById (R.id.TV4); // مربع العملية الحسابية // تصفير الخانات tv1.setText(""); tv2.setText(""); bn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv2.setText(tv1.getText()); tv1.setText(tv2.getText() + "1"); } }); bn2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv2.setText(tv1.getText()); tv1.setText(tv2.getText() + "2"); } }); bn3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv2.setText(tv1.getText()); tv1.setText(tv2.getText() + "3"); } }); bn4.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv2.setText(tv1.getText()); tv1.setText(tv2.getText() + "4"); } }); bn5.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv2.setText(tv1.getText()); tv1.setText(tv2.getText() + "5"); } }); bn6.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv2.setText(tv1.getText()); tv1.setText(tv2.getText() + "6"); } }); bn7.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv2.setText(tv1.getText()); tv1.setText(tv2.getText() + "7"); } }); bn8.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv2.setText(tv1.getText()); tv1.setText(tv2.getText() + "8"); } }); bn9.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv2.setText(tv1.getText()); tv1.setText(tv2.getText() + "9"); } }); bn0.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv2.setText(tv1.getText()); tv1.setText(tv2.getText() + "0"); } }); ba1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv3.setText(tv1.getText()); tv4.setText("+"); tv1.setText(""); } }); ba2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv3.setText(tv1.getText()); tv4.setText("-"); tv1.setText(""); } }); ba3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv3.setText(tv1.getText()); tv4.setText("×"); tv1.setText(""); } }); ba4.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv3.setText(tv1.getText()); tv4.setText("÷"); tv1.setText(""); } }); ba5.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { double a = Double.parseDouble(tv3.getText().toString()); double b = Double.parseDouble(tv1.getText().toString()); double c; String d; String e = tv4.getText().toString(); switch (e) { case "+": c = a + b; d = Double.toString(c); tv1.setText(d); tv2.setText(""); tv3.setText(""); tv4.setText("="); break; case "-": c = a - b; d = Double.toString(c); tv1.setText(d); tv2.setText(""); tv3.setText(""); tv4.setText("="); break; case "×": c = a * b; d = Double.toString(c); tv1.setText(d); tv2.setText(""); tv3.setText(""); tv4.setText("="); break; case "÷": c = a / b; d = Double.toString(c); tv1.setText(d); tv2.setText(""); tv3.setText(""); tv4.setText("="); break; default: tv1.setText("Err"); tv2.setText(""); tv3.setText(""); tv4.setText("="); break; } } }); bac.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv1.setText(""); tv2.setText(""); tv3.setText(""); tv4.setText(""); } }); } protected void setIntent(int i) { // TODO Auto-generated method stub } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } }

bt-lejos icon bt-lejos

This will allow you to communicate from an Android device over Bluetooth with a simple Lejos program running on a Lego NXT robot.

llama_index icon llama_index

LlamaIndex is a data framework for your LLM applications

mininet icon mininet

Emulator for rapid prototyping of Software Defined Networks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.