我正在學習android ..以及我在這裏添加了代碼catchmayuri.blogspot.in/2010/12/sample-android-login-application.html我一直在執行該代碼的應用程序沒有運行。 ..android登錄初學者類
<ImageButton android:id="@+id/buttonLogin"
android:layout_width="140dp"
android:layout_height="50dp"
android:background="@drawable/login5"
/>
這是XML 的代碼如下因素是mainAcivity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
unameEdit = (EditText) findViewById(R.id.txtUsername);
passEdit = (EditText) findViewById(R.id.txtPassword);
loginButton = (Button) findViewById(R.id.buttonLogin);
System.out.println("button login obtaied");
loginButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
user = unameEdit.getText().toString().trim();
pass = passEdit.getText().toString().trim();
if (user.equalsIgnoreCase(pass)) {
Toast.makeText(MainActivity.this, "Login Successfull",
Toast.LENGTH_LONG).show();
// setContentView(R.layout.secondpage); Call Intent
Intent i = new Intent(MainActivity.this, SecondClass.class);
startActivity(i);
} else {
Toast.makeText(MainActivity.this,
"Check the Username/password", Toast.LENGTH_LONG)
.show();
}
}
});
}
}
apk文件dosent運行的代碼......我到底做錯了什麼??? ?
當你運行你的項目時會出現什麼錯誤。 – Ankit
emulato r說應用程序未能啓動..日誌貓是空的 – Alvin