如何通过按钮执行插入操作在android中单击

时间:2011-12-26 07:11:33

标签: android

朋友,我在插入过程中遇到了麻烦。insert1.setOnClickListener(new View.OnClickListener()显示Error.Anyone有解决方案建议我

@Override

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

setContentView(R.layout.insert);

ename=(EditText)findViewById(R.id.editText1);

eid=(EditText)findViewById(R.id.editText2);

insert1.setOnClickListener(new View.OnClickListener() {


        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
        empname=ename.getText().toString();
        empid=Integer.parseInt(eid.getText().toString());
        Intent insert=new Intent(Insert.this,DBAdapter.class);
        Bundle bundle=new Bundle();
        bundle.putString("EMPNAME", empname);
        bundle.putInt("EMPID", empid);
        insert.putExtras(bundle);
        startActivityForResult(insert,1);
        //DBAdapter db = null;
        //db.insert(empname,empid);
        }
    });
}

0 个答案:

没有答案