Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
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 more
Archives
Today
Total
관리 메뉴

기록

안드로이드 스튜디오 double 버튼만들기 본문

JAVA

안드로이드 스튜디오 double 버튼만들기

9400 2022. 12. 28. 20:10

 

 

package kr.co.aiai.app;

import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity2 extends AppCompatActivity {

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

        Button btn = (Button)findViewById(R.id.btn);
        EditText et = findViewById(R.id.et);


        btn.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {

                String a = et.getText().toString();
                int aa = Integer.parseInt(a);
                aa *= 2;
                et.setText(aa+"");
            }
        });


    }


}

누르면 2배가 된다 

Comments