티스토리 뷰
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);
}
};
'Android > Android Studio' 카테고리의 다른 글
컨트롤 배치 (수직, 수평) (0) | 2019.04.04 |
---|---|
컨트롤 테이블 배치 (0) | 2019.04.04 |
DatePicker Dialog, TimePicker Dialog (0) | 2019.04.04 |
질문 다이얼로그 (0) | 2019.04.04 |
Gradle sync failed: Could not find com.android.tools.build:gradle:3.0.0. (0) | 2019.03.22 |
- Total
- Today
- Yesterday