文件名称:Android簡易計算機
文件大小:1.37MB
文件格式:ZIP
更新时间:2017-01-01 09:43:04
android
package tw.android; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class Main extends Activity { private class BtnListener implements OnClickListener { @Override public void onClick(View v) { // TODO Auto-generated method stub String h = Float.toString(Float.parseFloat(edtxt1.getText().toString()) +Float.parseFloat(edtxt2.getText().toString())); String l = Float.toString(Float.parseFloat(edtxt1.getText().toString()) -Float.parseFloat(edtxt2.getText().toString())); switch(v.getId()) { case R.id.button1: txtview.setText("+"); txt5.setText("你使用了加法"); break; case R.id.button2: txtview.setText("-"); txt5.setText("你使用了減法"); break; case R.id.button3: { if (txtview.getText()=="+") txtresult.setText("兩數相加="+h); if (txtview.getText()=="-") txtresult.setText("兩數相減="+l); break; } } } } private EditText edtxt1; private EditText edtxt2; private TextView txtview; private TextView txtresult; private TextView txt5; private Button btnplus; private Button btnminus; private Button btnequal; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getViews(); setListeners(); } private void setListeners() { BtnListener btnListener = new BtnListener(); btnplus.setOnClickListener(btnListener ); btnminus.setOnClickListener(btnListener ); btnequal.setOnClickListener(btnListener); } private void getViews() { edtxt1 = (EditText)findViewById(R.id.editText1); edtxt2 = (EditText)findViewById(R.id.editText2); txtresult = (TextView)findViewById(R.id.textView4); txtview = (TextView)findViewById(R.id.textView2); txt5 = (TextView)findViewById(R.id.textView5); btnplus = (Button)findViewById(R.id.button1); btnminus = (Button)findViewById(R.id.button2); btnequal = (Button)findViewById(R.id.button3); } @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; } }
【文件预览】:
HWrelative
----bin()
--------classes.dex(610KB)
--------HWrelative.apk(259KB)
--------res()
--------jarlist.cache(120B)
--------dexedLibs()
--------classes()
--------resources.ap_(48KB)
--------AndroidManifest.xml(854B)
----res()
--------drawable-ldpi()
--------values-v11()
--------menu()
--------values-v14()
--------drawable-hdpi()
--------drawable-xhdpi()
--------drawable-xxhdpi()
--------values()
--------values-sw720dp-land()
--------drawable-mdpi()
--------values-sw600dp()
--------layout()
----proguard-project.txt(781B)
----ic_launcher-web.png(102KB)
----assets()
----gen()
--------tw()
----.settings()
--------org.eclipse.jdt.core.prefs(177B)
----src()
--------tw()
----.project(846B)
----.classpath(475B)
----project.properties(563B)
----AndroidManifest.xml(854B)
----libs()
--------android-support-v4.jar(543KB)