티스토리 뷰

Android/Java

[Java]  BuildConfig

혀가 길지 않은 개발자 2020. 8. 7. 16:09

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/btnClick"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:textAllCaps="false"
        android:text="Is this BuildConfig.DEBUG?"
        android:textSize="20dp"
        android:textStyle="italic"/>

</LinearLayout>

activity_main.xml

 

 

 

 

 

 

MainActivity.java

package com.jwsoft.javaproject;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    Button btnClick;

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

        btnClick = findViewById(R.id.btnClick);

        btnClick.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (BuildConfig.DEBUG) {
                    Toast.makeText(getApplicationContext(), "BuildConfig.DEBUG", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

}

실행 결과

 

 

 

 

'Android > Java' 카테고리의 다른 글

[Java]  NestedScrollView  (0) 2020.08.10
[Java]  ProgressBar  (0) 2020.08.07
[Java]  enum  (0) 2020.08.07
[Java]  Generics  (2)  (0) 2020.08.06
[Java]  Toolbar  +  include  (0) 2020.08.05
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/01   »
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
글 보관함