-
날짜 / 시간 예약 구현안드로이드 스튜디오 2021. 12. 31. 01:01
1) 아날로그 시계, 디지털 시계, 크로노미터, 타임피커와 데이트피커
<AnalogClock android:layout_width="match_parent" android:layout_height="wrap_content" /> <DigitalClock android:layout_width="match_parent" android:layout_height="wrap_content"/> <Chronometer android:id="@+id/chronometer1" android:layout_width="match_parent" android:layout_height="wrap_content" android:format="시간 측정 : %s" android:gravity="center" android:textSize="30dp" /> <TimePicker android:timePickerMode="spinner" android:layout_width="match_parent" android:layout_height="wrap_content" /> <DatePicker android:datePickerMode="spinner" android:layout_width="match_parent" android:layout_height="wrap_content" />
- 활용
<DatePicker android:datePickerMode="spinner" android:layout_width="match_parent" android:layout_height="wrap_content" /> <TimePicker android:timePickerMode="spinner" android:layout_width="match_parent" android:layout_height="wrap_content" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <AnalogClock android:layout_width="match_parent" android:layout_height="match_parent" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <DigitalClock android:layout_width="match_parent" android:layout_height="match_parent" android:textColor="#00FF00" android:textSize="30dp"/> <Chronometer android:id="@+id/chronometer1" android:layout_width="match_parent" android:layout_height="match_parent" android:format="시간 측정 : %s" android:gravity="center" android:textSize="30dp" /> </LinearLayout> </LinearLayout>
2) 자동완성 텍스트뷰와 멀티 자동완성 텍스트뷰
- xml
<AutoCompleteTextView android:id="@+id/autoCompleteTextView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:completionHint="선택하세요" android:completionThreshold="2" android:hint="자동완성텍스트뷰" > </AutoCompleteTextView> <MultiAutoCompleteTextView android:id="@+id/multiAutoCompleteTextView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:completionHint="선택하세요" android:completionThreshold="2" android:hint="멀티자동완성텍스트뷰" />
- Java
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String[] items = { "CSI-뉴욕", "CSI-라스베가스", "CSI-마이애미", "Friends", "Fringe", "Lost" }; AutoCompleteTextView auto = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, items); auto.setAdapter(adapter); MultiAutoCompleteTextView multi = (MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteTextView1); CommaTokenizer token = new MultiAutoCompleteTextView.CommaTokenizer(); multi.setTokenizer(token); multi.setAdapter(adapter); } }
3) 프로그래스바, 시크바, 레이팅바
<ProgressBar style="?android:attr/progressBarStyleHorizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp" android:max="100" android:progress="20" android:secondaryProgress="50" /> <SeekBar android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp" android:progress="20" /> <RatingBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="20dp" android:numStars="5" android:rating="1.5" android:stepSize="0.5" />
'안드로이드 스튜디오' 카테고리의 다른 글
옵션메뉴, 컨텍스트 메뉴, 대화상자 (0) 2021.12.31 뷰 컨테이너 (0) 2021.12.31 계산기, Java 코드로 화면 구성 , 레이아웃 (0) 2021.12.31 계산기, 홈페이지 연결, 인텐트 (0) 2021.12.30 자바 문법 예제 (0) 2021.12.30