TouchCalculator - Android 平台上的触摸式计算器,
投稿于 被查看 11225 次 评论:223
TouchCalculator - Android 平台上的触摸式计算器,
<无详细内容>1.[图片] tcMockup.png
2.[图片] tc1.PNG
3.main.java
package com.pragmatouch.calculator; import android.app.Activity; import android.os.Bundle; import android.widget.AdapterView; import android.widget.GridView; import android.view.View; import android.view.View.OnClickListener; public class main extends Activity { GridView mKeypadGrid; KeypadAdapter mKeypadAdapter; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Get reference to the keypad button GridView mKeypadGrid = (GridView) findViewById(R.id.grdButtons); // Create Keypad Adapter mKeypadAdapter = new KeypadAdapter(this); // Set adapter of the keypad grid mKeypadGrid.setAdapter(mKeypadAdapter); // Set button click listener of the keypad adapter mKeypadAdapter.setOnButtonClickListener(new OnClickListener() { @Override public void onClick(View v) { Button btn = (Button) v; // Get the KeypadButton value which is used to identify the // keypad button from the Button's tag KeypadButton keypadButton = (KeypadButton) btn.getTag(); // Process keypad button ProcessKeypadInput(keypadButton); }}); }); mKeypadGrid.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v,int position, long id) { // This will not help us catch button clicks! } }); } }
用户评论