상세 컨텐츠

본문 제목

[안드로이드] 통화코드 통화상징 가져오는 드롭다운메뉴(DropDown Menu) 쉽게 만드는 방법

안드로이드

by aries574 2022. 1. 30. 11:41

본문


이번 시간에는 통화코드 통화상징 가져오는

드롭다운메뉴 쉽게 만드는 방법에 대하여

알아보겠습니다.


목차

1. 실행 화면

2. 라이브러리 등록

3 메인 화면 구성 activity_main.xml

4. 메인 코드 구현 MainActivity.java


1. 실행 화면



2. 라이브러리 등록

build.gradle(Module:프로젝트명:app)

dependencies 괄호 안에 아래 코드를 넣어주시면 됩니다.

    implementation 'com.github.scrounger:countrycurrencypicker:1.1.1'
    implementation 'com.google.guava:guava:27.0.1-android'

참조문서

https://github.com/Scrounger/CountryCurrencyPicker

 

GitHub - Scrounger/CountryCurrencyPicker: CountryCurrencyPicker is an android picker library for country and / or currency. You

CountryCurrencyPicker is an android picker library for country and / or currency. You can implement it as fragment or dialog. It offers the option to search for country values and / or currency val...

github.com

 


3 메인 화면 구성 activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/text_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="30sp" />

    <com.scrounger.countrycurrencypicker.library.Buttons.CountryCurrencyButton
        android:id="@+id/countryc_picker"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="100dp"
        app:country_code="US"
        app:show_currency="true" />
</LinearLayout>



4. 메인 코드 구현 MainActivity.java

public class MainActivity extends AppCompatActivity {

    TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textView = findViewById(R.id.text_view);

        CountryCurrencyButton currencyButton = findViewById(R.id.countryc_picker);
        currencyButton.setOnClickListener(new CountryCurrencyPickerListener() {
            @Override
            public void onSelectCountry(Country country) {

                Currency currency = country.getCurrency();

                String code = currency.getCode();
                String symbol = currency.getSymbol();

                textView.setText("통화코드:" + code + "\n" + "통화상징:" + symbol);
            }
            @Override
            public void onSelectCurrency(Currency currency) {

            }
        });

    }//onCreate

} //MainActivity

2022.01.22 - [안드로이드] - [안드로이드] 스피너(Spinner) 검색(Search)하는 기능 넣는 방법

 

[안드로이드] 스피너(Spinner) 검색(Search)하는 기능 넣는 방법

이번 시간에는 스피너(Spinner)에 검색하는 기능을 넣는 방법을 알아보겠습니다. 목차 1. 실행 화면 2. 라이브러리 등록 3. 메인 화면 구성 activity_main.xml 4. 메인 코드 구현 MainActivity.java 1. 실행 화면.

aries574.tistory.com

2020.06.09 - [안드로이드] - [안드로이드]스피너 드롭다운 셀렉트박스 배경색 바꾸기 setOnItemSelectedListener

 

[안드로이드]스피너 드롭다운 셀렉트박스 배경색 바꾸기 setOnItemSelectedListener

2020/06/08 - [안드로이드] - [안드로이드] 라디오버튼 예제 배경색 바꾸기 이번에는 스피너를 이용해서 배경색을 바꿔보겠습니다. HTML에서는 드롭다운리스트, 셀렉트박스라고 불리고 있습니다. actv

aries574.tistory.com

2021.12.12 - [안드로이드] - [안드로이드] Custom Spinner 쉽게 만드는 방법

 

[안드로이드] Custom Spinner 쉽게 만드는 방법

이번 시간에는 스피너를 내맘대로 바꿔보겠습니다. 미리 알아보자면 아이콘 넣기, 글씨색깔 바꾸기, 배경색상 바꾸기 정도 입니다. 1. 데이터 담을 클래스 만들기 (Fruit.java) public class Fruit{ private

aries574.tistory.com

 

반응형

관련글 더보기

댓글 영역