点击是在项目中给出错误 [英] on click is giving error in project
本文介绍了点击是在项目中给出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个应用程序项目,我想在其中创建一个数据库,并将在editText中输入的一些细节添加到表中。点击OnBtnIncludeClick按钮后,我收到一条错误消息不幸的是,应用程序已停止。我可以在editText中输入一些文字。
I am developing an apps project in which I want to create a database and add some details entered in editText into a table. On click of button 'OnBtnIncludeClick' I get an error stating 'Unfortunately, apps has stopped'. I am able to enter some text in editText.
public class listmasteritems extends Activity implements OnClickListener{
public EditText editText;
SQLiteDatabase db;
String AccountName;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listmasteritems);
editText = (EditText)findViewById(R.id.idRelationShip);
editText.setOnClickListener(this);
db=openOrCreateDatabase("myDb",MODE_PRIVATE,null);
db.execSQL("CREATE TABLE IF NOT EXISTS TblAccountMaster (AccountId int primary key, AccountName varchar ) ");
}
public void onBtnIncludeClick( View v)
{
AccountName=editText.getText().toString();
db.execSQL( "INSERT INTO TblAccountMaster VALUES('"+AccountName+"');");
db.close();
}
推荐答案
检查一下:在Android上处理输入和存储 [ ^ ]
这篇关于点击是在项目中给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文