티스토리 뷰

반응형

public ArrayAdapter<String> GetMagamList() {
  String Sql, CloseTime, Str;
  Cursor Cur;
  ArrayAdapter<String>  Adapter;
  
  mFos    = new FOSDBHandler(this);
  arMagamList  = new ArrayList<String>();
  arMagamShowList = new ArrayList<String>();
  
  Sql = "SELECT DISTINCT close_time FROM CLOSE_DATA ORDER BY close_time DESC LIMIT 200 ";
  Cur = mFos.QueryProcessing(Sql);
  
  if(Cur.getCount() > 0) {
   while(Cur.moveToNext()) { 
    CloseTime = Cur.getString(0);
    arMagamList.add(CloseTime);
    
    Str =  CloseTime.substring(0, 2) + "/" + CloseTime.substring(2, 4) + "/" + CloseTime.substring(4, 6) + " " +
      CloseTime.substring(6, 8) + ":" + CloseTime.substring(8, 10) + ":" + CloseTime.substring(10, 12);
    arMagamShowList.add(Str);
   }
  }
 
  Adapter = new ArrayAdapter<String> (DaySum.this, android.R.layout.simple_list_item_single_choice,  arMagamShowList);
  Cur.close();
  
  return Adapter;
 }

 

 

 

 

Button.OnClickListener mClick = new View.OnClickListener() {
  int      mSelect = 0;
  ArrayAdapter<String> MagamAdapter;
  String     Magam = "", ShowMagam = "";
  int      BtnType;
  
  @Override
     public void onClick(View v) {
   MagamAdapter = GetMagamList();
   
   
   new AlertDialog.Builder(DaySum.this)
   .setTitle("마감 선택")
   .setIcon(R.drawable.icon)
   .setSingleChoiceItems(MagamAdapter, mSelect, new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
     mSelect = which;
    }
   })
   .setPositiveButton("선택", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
     Magam   = arMagamList.get(mSelect);
     ShowMagam  = arMagamShowList.get(mSelect);
     
     if(BtnType == R.id.BtnStart) {
      mStart = Magam;
      TxtStart.setText(ShowMagam);
     } else {
      mEnd = Magam;
      TxtEnd.setText(ShowMagam);
     }
     
     Toast.makeText(DaySum.this, ShowMagam, Toast.LENGTH_SHORT).show(); 
    }
   })
   .setNegativeButton("취소", null)
   .show();
   
   switch(v.getId()) {
       case R.id.BtnStart  : BtnType = R.id.BtnStart;
             break;
          
       case R.id.BtnEnd  :  BtnType = R.id.BtnEnd;
          break;
   }
   
   // GetDayList(true);
  }
 };

 

반응형
댓글
반응형
최근에 올라온 글
Total
Today
Yesterday