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 | 31 |
Tags
- CS
- ์นด์นด์ค์ฝํ
- ํฐ์คํ ๋ฆฌ์ฑ๋ฆฐ์ง
- ํ๋ก๊ทธ๋๋จธ์ค
- Kotlin
- ์๋๋ก์ด๋์คํ๋์ค
- ์ค๋ธ์
- ์ฝํ
- ์๋ฃ๊ตฌ์กฐ
- ์ ๋ณด์ฒ๋ฆฌ๊ธฐ์ฌ
- select
- Android
- join
- ์คํฐ๋
- ์๊ณ ๋ฆฌ์ฆ
- ํผ๊ณตํ
- ์ธํ๋ฐ
- ์ ์ฒ๊ธฐ
- ์ฝํ๋ฆฐ
- MySQL
- ํผ๊ณต์ฑ๋ฆฐ์ง
- ๊ธฐ์ ๋ฉด์
- java
- Til
- SQL
- ์๋๋ก์ด๋
- doitandroid
- ํผ๊ณต๋จ
- ์๋ฐ
- groupby
Archives
- Today
- Total
Welcome! Everything is fine.
[Android] ๋ทฐ ๋ฐ์ธ๋ฉ ํ๊ธฐ ๋ณธ๋ฌธ
728x90
๐ ๋ทฐ ๋ฐ์ธ๋ฉํ๊ธฐ
์๋ฐ์์ ๋ทฐ๋ฐ์ธ๋ฉ ํ๋ ๋ฐฉ๋ฒ์ ์์๋ณด์! Gradle Scripts > build.gradle(Module: ~)์์ ์ ์ ํ ์์น์(๋๋ buildTypes ์์ ๋ฃ์๋ค.) ์๋ ์ฝ๋๋ฅผ ๋ฃ๊ณ Sync Now๋ฅผ ๋๋ ๋ค.
buildFeatures {
viewBinding = true
}
๊ทธ๋ฆฌ๊ณ MainActivity.java๋ก ๋์์์ private ActivityMainBinding binding; ์ด๋ผ๊ณ ์ ์ธํด์ค ํ onCreate( )ํจ์ ์์์ ๋ค์๊ณผ ๊ฐ์ด ์ ์ด์ค๋ค.
public class MainActivity extends AppCompatActivity {
private ActivityMainBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
}
๊ทธ๋ฌ๋ฉด ์๋์ ๊ฐ์ด findViewById๋ฅผ ๋์ฒดํ์ฌ ๋ ๊ฐํธํ๊ฒ ์ฌ์ฉํ ์ ์๋ค.
binding.button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
println("๋ฒํผ ๋๋ฆผ.");
}
});
์ฐธ๊ณ ๋ก ์ฝํ๋ฆฐ์์๋ gradle์ ์ ๋ ๊ฒ์ ๋๊ฐ๊ณ , MainActivity.kt์์ ๋ค์๊ณผ ๊ฐ์ด ๋ทฐ๋ฐ์ธ๋ฉ ํ๋ค.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
}
'Android' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Android/study] ๋ถํ์ํ ํ ์คํธ ์ ๊ฑฐํ๊ธฐ, ๋ฆฌ์ฌ์ดํด๋ฌ๋ทฐ ๋ง๋ค๊ธฐ (0) | 2022.05.24 |
---|---|
[Andorid] Volley ์ฌ์ฉ๋ฒ (0) | 2022.05.14 |
[Android] ํ๋๊ทธ(Flag) (0) | 2022.03.11 |
[Android] ์ธํ ํธ(Intent) ์ดํด๋ณด๊ธฐ (0) | 2022.03.10 |
[Android] ์๋๋ก์ด๋ ์ฑ์ ๊ตฌ์ฑ์์, ํ๋ฉด(์กํฐ๋นํฐ) ์ ํํ๊ธฐ (0) | 2022.03.09 |