如果第一個活動已經有一個acount,那麼第一個活動會取用戶的名字和密碼,第二個view類將會打開,否則用戶應該首先唱歌。Android force關閉解析整數和引用按鈕
我有兩個共同的問題:
1-的整數原因力解析由logcat的接近通知
2-第二按鈕化妝也強制關閉
package sarah.android;
import android.R.integer;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class SelesMeter2Activity extends Activity
implements OnClickListener{
EditText ed1;
EditText ed2;
Button b1;
Button b2;
SQLiteDatabase sql;
Cursor c;
Intent in;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ed1=(EditText) findViewById(R.id.ed1);
ed2=(EditText) findViewById(R.id.ed2);
b1= (Button) findViewById(R.id.bt1);
b2= (Button) findViewById(R.id.bt2);
b1.setOnClickListener(this);
b2.setOnClickListener(this);
sql=openOrCreateDatabase("db",0, null);
sql.execSQL("CREATE TABLE if not exists " +
"Employee2 (password integer NOT NULL PRIMARY KEY,name text NOT NULL)");
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
//log in
if(arg0.getId()==R.id.bt1)
{
String name=ed1.getText().toString();
Integer pass=Integer.parseInt
(ed2.getText().toString());
if(c.getCount()!=0)
{
c=sql.rawQuery("select * from Employee", null);
while(c.moveToNext())
{
if(name.equals("c.getString(1)")&&pass==c.getInt(0))
{
in=new Intent(this,secondview.class);
startActivity(in);
break;
}
}
}
else
{
Toast.makeText(this,"please sign up first or enter " +
"correct data", 2000).show();
}
}
else if(arg0.getId()==R.id.bt2)
{
//sign up
Intent in2=new Intent(this,signup.class);
startActivity(in);
}
}
}
輸入用戶新信息的唱歌班: 包sarah.android;
你有什麼問題嗎? – Raptor 2012-08-11 03:25:57
我想將edittext的值轉換成整數,不用強制關閉 – Syamic 2012-08-11 03:28:22
我有編號formate日誌貓異常 – Syamic 2012-08-11 03:29:21