匿名子类调用父类成员函数on_Previous();

来源:互联网 发布:iphone4 ios7越狱优化 编辑:程序博客网 时间:2024/06/06 06:34
public class Input_numActivity extends Activity {Button btn_call, btn_previous;EditText edt_num;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);// 设置布局setContentView(R.layout.call_phone);edt_num = (EditText) findViewById(R.id.edt_call_num);btn_call = (Button) findViewById(R.id.sys_call);btn_previous = (Button) findViewById(R.id.Previous);btn_call.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubString phoneString = edt_num.getText().toString();Pattern pattern = Pattern.compile("[0-9]*");if (pattern.matcher(phoneString).matches()) {// 调用系统拨打电话Uri uri = Uri.parse("tel:" + phoneString);Intent sys_call_Intent = new Intent(Intent.ACTION_DIAL, uri);startActivity(sys_call_Intent);}}});btn_previous.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubon_Previous();}});}//处理back键@Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) {// TODO Auto-generated method stubif (keyCode==KeyEvent.KEYCODE_BACK) {on_Previous();return true;}else {return super.onKeyDown(keyCode, event);}}void on_Previous(){Bundle bundle = new Bundle();String phoneString = edt_num.getText().toString();bundle.putString("PHONE_NUM", phoneString);Input_numActivity.this.setResult(RESULT_CANCELED, Input_numActivity.this.getIntent().putExtras(bundle));Input_numActivity.this.finish();}}

原创粉丝点击