안녕하세요

몇가지 기능이 추가된 시간표를 만들고 있습니다.

 

**************** 문제점 : Button과 EditText가 클릭이 안됩니다. ********************

 

EditText : xml에서 초기에 clickable, focusable, focusableInTouchMode 를 모두 false로 설정

                 -> EDITABLE 상태가 되면 (화면 하단의 EDIT 버튼 클릭)  위 세가지 속성이 true로 변경되어 입력가능

Button : xml에서는 clickable포함 focusable과 foucsableInTouchMode 모두 아예 속성 설정하지 않음.

              -> onClick() 메소드에서 EDITABLE 상태일 경우 DatePicker 다이얼로그 호출,

                                                        NO_EDITABLE 상태일 경우 그냥 종료( return; )

 

****************************************************************************

 

비슷한 동작원리의 다른 액티비티도

처음에는 잘 작동하다가 코딩 다하니까

클릭도 안되고 데이트피커도 안나와서

원인을 찾다가 결국 못찾아서

그 액티비티 아예 첨부터 다시 다 코딩했는데...

이거 또.......처음에는 잘 되다가

코딩 다하니까 클릭도 안되고 데이트피커도 안나오네요...

아 답답해서 원인을 찾고 싶어도 도저히 모르겠습니다..ㅠㅠ

 

도와주세요ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ

 

 

 

 

************************************************코드******************************

package com.hufs.timetable;

import java.util.Calendar;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Toast;

public class TeamProject extends Activity implements View.OnClickListener {

    /** Called when the activity is first created. */
 static final int NO_EDITABLE = 0;
 static final int EDITABLE = 1;
 static final int INSERT = 0;
 static final int UPDATE = 1;
 static final int DATE_DIALOG_ID=0;
 
 private EditText titleET, topicET, detailET;
 private Button chkDateBtn, dueDateBtn;
 private Button clickedBtn;
 
 private int mYear, mMonth, mDay;
 
 private String cell_id, subject;
 private int state, howEdit;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.teamproject);
       
       
        chkDateBtn = (Button)findViewById(R.id.chkDateBtn);
        dueDateBtn = (Button)findViewById(R.id.dueDateBtn);
       
        chkDateBtn.setOnClickListener(this);
        dueDateBtn.setOnClickListener(this);
       
        final Calendar c = Calendar.getInstance(); 
        mYear = c.get(Calendar.YEAR);
        mMonth = c.get(Calendar.MONTH);
        mDay = c.get(Calendar.DAY_OF_MONTH);
       
        topicET = (EditText)findViewById(R.id.topicET);
        titleET = (EditText)findViewById(R.id.titleET);
        detailET = (EditText)findViewById(R.id.detailET);
    }
   
    public void onResume() {
     super.onResume();
        setContentView(R.layout.teamproject);
        state = NO_EDITABLE;
//       setData();
    }
   
    public void onClick(View v) {
     
     if(state==EDITABLE) {
      showDialog(DATE_DIALOG_ID);
      clickedBtn = (Button)v;
      Toast.makeText(this, subject + "눌렸음", Toast.LENGTH_LONG).show();
      Log.i("tag", "onClick() 호출됨 : 수정 가능 상태에서");
     }
     
     else if(state==NO_EDITABLE)
      Toast.makeText(this, "수정불가 눌렸음", Toast.LENGTH_LONG).show();
      Log.i("tag", "onClick() 호출됨 : 수정불가상태에서");
      return;
    }
 
 protected Dialog onCreateDialog(int id) {
     switch(id) {
     case DATE_DIALOG_ID :
      return new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay);
     }
     return null;
    }
 
    private void updateDateDisplay(Button b) {   
     b.setText(new StringBuilder().append(mYear).append(" - ")
        .append(mMonth+1).append(" - ")
        .append(mDay));
    }
     
    private DatePickerDialog.OnDateSetListener mDateSetListener =
     new DatePickerDialog.OnDateSetListener() {
   
  public void onDateSet(DatePicker view, int year, int monthOfYear,
    int dayOfMonth) {
    mYear = year;
    mMonth = monthOfYear;
    mDay = dayOfMonth;
    
    if(clickedBtn.getId() == R.id.chkDateBtn)
     updateDateDisplay(chkDateBtn);
    else
     updateDateDisplay(dueDateBtn);
  }
 };

 public void editBtnClick(View v) {
  
  Button editBtn = (Button)findViewById(R.id.teamprojectEditBtn);
  
  if( state == NO_EDITABLE ) {
      Toast.makeText(this, subject + " :  프로젝트 정보를 입력하세요!", Toast.LENGTH_LONG).show();

      titleET.setFocusable(true); titleET.setClickable(true); titleET.setFocusableInTouchMode(true);
      topicET.setFocusable(true); topicET.setClickable(true); topicET.setFocusableInTouchMode(true);
      detailET.setFocusable(true); detailET.setClickable(true); detailET.setFocusableInTouchMode(true);
      
      editBtn.setText(R.string.save);
      state = EDITABLE;
     }
  
  else if( state == EDITABLE ) {
   
   titleET.setFocusable(false); titleET.setClickable(false); titleET.setFocusableInTouchMode(false);
      topicET.setFocusable(false); topicET.setClickable(false); topicET.setFocusableInTouchMode(false);
      detailET.setFocusable(false); detailET.setClickable(false); detailET.setFocusableInTouchMode(false);
      
      editBtn.setText(R.string.edit);
      state = NO_EDITABLE;
     }
  
    }
}