我有一个包含四个edittexts.In每个EditText上我只接受每个edittexts.Once我在第四输入值的EditText应该调用构造单个数字value.I设置requestFocus()方法主屏幕,火查询&应该返回我登录是否成功not.Instead,它给我消息“登录失败”错误登录在检索
这里是我的代码
edit4.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View arg0, int arg1, KeyEvent arg2)
{
// TODO Auto-generated method stub
if(edit4.getText().toString().length()==1)
{
ParentDBHelper helper = new ParentDBHelper(getApplicationContext(), "db_parents", null, 2);
SQLiteDatabase db=helper.getWritableDatabase();
Cursor c=db.rawQuery("SELECT * FROM tbl_countries", null);
// check if the table is empty
if (!c.moveToNext())
{
Toast.makeText(getApplicationContext(), "No data to display, please make sure you have already inserted data!", Toast.LENGTH_LONG).show();
db.close();
return false;
}
c.moveToPrevious();
// if the table is not empty, read the result into a string named display
while(c.moveToNext())
{
String
String no1=c.getColumnName(5);
if(no1==edit1.getText().toString()+edit2.getText().toString()+edit3.getText().toString()+edit4.getText().toString())
{
flag_status_pin=1;
Toast.makeText(getApplicationContext(), "Login Successful!!", Toast.LENGTH_LONG).show();
Intent dash1=new Intent(getApplicationContext(),DashBoard.class);
startActivity(dash1);
}
}
if(flag_status_pin==0)
{
Toast.makeText(getApplicationContext(), "Login Failed!!", Toast.LENGTH_LONG).show();
Intent homes=new Intent(getApplicationContext(),home.class);
startActivity(homes);
}
}//if
return false;
}});
感谢。
谢谢You.In哪种方法,我应该写的代码? – swanand 2012-04-13 14:31:04
@swanand:的onCreate()将fine..you可以postthe更新的代码,如果ü面对任何问题 – Akhil 2012-04-14 03:51:45