试图保存日历年android工作室的每一天的笔记

时间:2017-12-16 18:13:57

标签: java android

我没有收到任何错误,但每次我尝试更改日历时我的应用程序停止工作都不起作用,即使我按下保存按钮它也一直停止工作,然后我添加代码与数组它工作正常

公共类Calendar扩展了AppCompatActivity {

private CalendarView calendarView;
private TextView currentDate;
private Button btnsavenote;
private EditText newNote, showNote;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_calendar);
    calendarView = (CalendarView) findViewById(R.id.calen_v);
    currentDate = (TextView) findViewById(R.id.currentDate);
    btnsavenote = (Button) findViewById(R.id.save_note);
    newNote = (EditText) findViewById(R.id.newNote);
    showNote = (EditText) findViewById(R.id.shownote);
    final String [][] array = new String[31][12];



    calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
        @Override
        public void onSelectedDayChange(@NonNull CalendarView view, int year, int month, int dayOfMonth) {
        String tDate = (dayOfMonth) + "/" + month + "/" + year;
        currentDate.setText(tDate);
        }
    });

    btnsavenote.setOnClickListener(new View.OnClickListener() {
        String MytextMessage = newNote.getText().toString();
        @Override
        public void onClick(View v) {
            int a;
            int b;
            a = Integer.parseInt(array [30][2]);
            b = Integer.parseInt(array [31][2]);
            array[a][b] = MytextMessage;
        }
    });
}

}

0 个答案:

没有答案