๋ฐ์ํ
Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- Pandas
- ํ์ด์ฌ
- ์น๋์๋ณด๋ ๊ธฐ์ด
- ์๋ฐ์คํฌ๋ฆฝํธ ๊ณต๋ถ
- MySQL
- ์๋๋ก์ด๋ ์ฑ ๊ฐ๋ฐ
- Streamlit๊ธฐ์ด
- ๋ฐ์ดํฐ๋ฒ ์ด์ค
- JavaScript
- ์๋ฐํ๋ก๊ทธ๋๋ฐ
- ์๋ฐ
- ํ๋ค์ค
- ํ์ด์ฌ๊ณต๋ถ
- ์คํธ๋ฆผ๋ฆฟ ๊ธฐ๋ณธ
- RESTful API
- ์๋ฐ์ด๋ณด
- ์๋ฐ๊ณต๋ถ
- Streamlit๊ธฐ๋ณธ
- db
- ์๋๋ก์ด๋ ์คํ๋์ค
- ํ๋ค์ค๊ณต๋ถ
- ์น๋์๋ณด๋ ์ ์
- ์๋ฐ์คํฌ๋ฆฝํธ
- Android
- serverless
- ์คํธ๋ฆผ๋ฆฟ
- ์๋ฐ๊ธฐ์ด
- Matplotlib ๊ธฐ์ด
- java
- streamlit
Archives
- Today
- Total
ruriruriya
[Android] ์๋๋ก์ด๋ - ์ ๋ ฌํ๋ ์ ๋ ํธ๋ฐ์ค ๋ง๋ค๊ธฐ Spinner ๋ณธ๋ฌธ
๐คAndroid/Java
[Android] ์๋๋ก์ด๋ - ์ ๋ ฌํ๋ ์ ๋ ํธ๋ฐ์ค ๋ง๋ค๊ธฐ Spinner
๋ฃจ๋ฆฌ์ผใ 2024. 1. 27. 18:55๋ฐ์ํ
์๋๋ก์ด๋ ์ฑ ๊ฐ๋ฐ ์ ์
๋ ํธ ๋ฐ์ค๋ฅผ ๊ตฌํํด๋ณด์.
๋ช
์นญ์ ์
๋ ํธ ๋ฐ์ค๊ฐ ์๋ Spinner์ด๋ค.
1. xml์์ spinner ์์ฑ
<Spinner
android:id="@+id/spinnerRecipe"
android:layout_width="80dp"
android:layout_height="wrap_content"/>
2. Activity.java์์ ์ค์
๋จผ์ Spinner ํ์ ๋ณ์์ item Array ๋ฅผ ์์ฑํ๋ค.
public class UserRecipeActivity extends AppCompatActivity {
Spinner spinnerRecipe;
String[] items = {"์ต์ ์","์ค๋๋ ์","๋ณ์ ์"};
...
}
๊ทธ๋ฆฌ๊ณ onCreate์์ ์ด๋ํฐ๋ฅผ ์์ฑํ์ฌ ์ธํ ํ๋ค.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_recipe);
spinnerRecipe = findViewById(R.id.spinnerRecipe);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item,items);
adapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
spinnerRecipe.setAdapter(adapter);
spinnerRecipe.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
3. ์์ฑ ํ๋ฉด
์ ํ ํ์ spinner ์ฐฝ์ ํ ์คํธ๊ฐ ์ ํํ ๋ด์ฉ์ผ๋ก ๋ฐ๋๋ค!
๋ฐ์ํ