在android中构造函数的概念,当按钮点击我称为构造函数显示在android

类转换异常我用这个构造函数来创建一个数据库,当一个按钮被点击这将调用构造函数,当我运行它显示java.lang.ClasscastException错误我的类型转换onClickListener是正确与否请人建议当按钮点击我称为构造函数显示在android

private static Context onClickListene;

public DatabaseHandler3(OnClickListener onClickListene)

{

super((Context) onClickListene,DATABASE_NAME, null, DATABASE_VERSION);

// TODO Auto-generated constructor stub

}

这是调用程序构造

button2.setOnClickListener(new OnClickListener()

{

public void onClick(View v)

{

try

{

final EditText edittxt4 = (EditText)findViewById(R.id.editText4);

final EditText edittxt5 = (EditText)findViewById(R.id.editText5);

final EditText edittxt6 = (EditText)findViewById(R.id.editText6);

String name=edittxt4.getText().toString();

String mailfamfri=edittxt5.getText().toString();

String phonefamfri=edittxt6.getText().toString();

int famatpos=mailfamfri.indexOf("@");

int famdotpos=mailfamfri.lastIndexOf(".");

int phonecount=phonefamfri.length();

if(name.equals(""))

{

Toast.makeText(FiveActivity.this, "You Family or Friends name is empty",Toast.LENGTH_LONG).show();

}

else if(mailfamfri.equals(""))

{

Toast.makeText(FiveActivity.this, "You Families or Friend's Mail-ID is Empty",Toast.LENGTH_LONG).show();

}

else if(famatpos<1 || famdotpos=mailfamfri.length())

{

Toast.makeText(FiveActivity.this, "You Families or Friend's Email-ID is not valid",Toast.LENGTH_LONG).show();

}

else if(phonefamfri.equals(""))

{

Toast.makeText(FiveActivity.this, "Phone Number is empty",Toast.LENGTH_LONG).show();

}

else if(phonefamfri.contains("[a-zA-z]"))

{

Toast.makeText(FiveActivity.this, "Phone Number should not contain any letters ",Toast.LENGTH_LONG).show();

}

else if(phonecount>10 || phonecount<10)

{

Toast.makeText(FiveActivity.this, "Phone Number Should Contain only 10 Numbers",Toast.LENGTH_LONG).show();

}

else

{

String phoneno="+91"+phonefamfri;

// Toast.makeText(FiveActivity.this, "Good"+phoneno,Toast.LENGTH_LONG).show();

DatabaseHandler3 db = new DatabaseHandler3(this);

//Toast.makeText(FiveActivity.this,name+mailfamfri+phoneno,Toast.LENGTH_LONG).show();

Log.d("Insert: ", "Inserting ..");

Log.d("Insert: ", "Inserting ..");

2014-02-08

Vji

+0

也请您发表调用部分 –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值