0
私はCodename 1つのSQLiteプロジェクトに取り組んでいますが、いくつかの問題が発生していますが、カレンダーの特定の日付をクリックしているときに、アプリケーションが起動してから最初に特定の日付をクリックすると、その日付が正確に表示されますが、2回目に前の日付の発生が現在の日付の発生に追加され、その合計が表示されます。どうすれば解決できますか?Codename 1つのSQLiteデータの問題
以下は私のコードです: - 私はこの問題への答えを得た
public class Customised extends Calendar{
ArrayList<String[]> data = new ArrayList<>();
public Customised(){
}
@Override
protected void updateButtonDayDate(Button dayButton, int currentMonth, int day) {
dayButton.setText(""+day);
dayButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try{
cur = db.executeQuery("SELECT Date from CalendarData WHERE Date = ? ", dateLabel.getText());
int columns = cur.getColumnCount();
if(columns > 0) {
boolean next = cur.next();
if(next) {
String[] columnNames = new String[columns];
for(int iter = 0 ; iter < columns ; iter++) {
columnNames[iter] = cur.getColumnName(iter);
}
while(next) {
Row currentRow = cur.getRow();
String[] currentRowArray = new String[columns];
for(int iter = 0 ; iter < columns ; iter++) {
currentRowArray[iter] = currentRow.getString(iter);
}
data.add(currentRowArray);
next = cur.next();
}
Object[][] arr = new Object[data.size()][];
data.toArray(arr);
}
}
}catch(IOException e){
e.printStackTrace();
}
int i;
for(i = 0 ; i< data.size(); i++){
Log.p(data.get(i)[0]);
}
Label a = new Label(dateLabel.getText());
Label b = new Label(""+i);
Container container1 = TableLayout.encloseIn(2, a,b);
calendar.add(container1);
Util.cleanup(data);
// dayButton.getAllStyles().setBgColor(0xef5555);
// dayButton.setText("* "+day);
}
});
}
@Override
protected Button createDay() {
Button day = new Button();
day.setAlignment(CENTER);
day.setUIID("CalendarDay");
day.setEndsWith3Points(false);
day.setTickerEnabled(false);
return day;
}
}
}
日付をクリックするとどのメソッドが呼び出されますか? – user1506104
dayButton.addActionListener(新しいActionListener(){ @Override public void actionPerformed(ActionEvent evt){ }} –