-1
package com.gofitness.www;
import android.app.Activity;
import android.os.Bundle
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class log extends Activity implements OnClickListener {
Button submit,bEdit, bGetInfo, bDelete;
TextView display;
EditText etRowInfo, username, password;
protected void onCreate(Bundle login) {
// TODO Auto-generated method stub
super.onCreate(login);
setContentView(R.layout.insert);
submit = (Button) findViewById(R.id.submit);
username = (EditText) findViewById(R.id.etUsername);
password = (EditText) findViewById(R.id.etPassword);
display = (TextView) findViewById(R.id.tvDisplay);
bEdit = (Button) findViewById(R.id.bEdit);
etRowInfo = (EditText) findViewById(R.id.etRowInfo);
bGetInfo = (Button) findViewById(R.id.bGetInfo);
bDelete = (Button) findViewById(R.id.bDelete);
submit.setOnClickListener(this);
etRowInfo.setOnClickListener(this);
}
public void onClick(View arg0) {
switch (arg0.getId()){
case R.id.submit:
display.setText("fdf");
boolean didItWork = true;
try{
String check = username.getText().toString();
String checkpass = password.getText().toString();
logindetails entry = new logindetails(log.this);
entry.open();
entry.createEntry(check, checkpass);
entry.close();
}catch (Exception e){
didItWork = false;
String error = e.toString();
display.setText(error);
}finally{
if (didItWork){
display.setText("WERKED");
}
}
break;
case R.id.bGetInfo:
display.setText("fdf");
String s = etRowInfo.getText().toString();
long l = Long.parseLong(s);
logindetails log = new logindetails(this);
log.open();
String returnedName = log.getName(l);
String returnedPassword = log.getPassword(l);
log.close();
password.setText(returnedPassword);
break;
case R.id.bEdit:
display.setText("fdf");
break;
case R.id.bDelete:
display.setText("fdf");
break;
}
}
}
看起來第一個案件的作品和按鈕改變了顯示文本視圖,但其餘的按鈕不起作用。一旦點擊沒有發生,但沒有錯誤。Android開發開關案例問題
任何人都知道爲什麼會發生這種情況?
乾杯