欢迎访问移动开发之家(rcyd.net),关注移动开发教程。移动开发之家  移动开发问答|  每日更新
页面位置 : > > > 内容正文

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!
     }
 });

 }

}

4.[文件] TouchCalculator.zip~295KB 下载(920)

用户评论