ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 날짜 / 시간 예약 구현
    안드로이드 스튜디오 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" />

    댓글

Designed by Tistory.