Android Custom CheckBox

// ata sub ar work tar mane amora calculator make korte parbo

package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.Toast;

import static com.example.myapplication.R.id.checkbox1;

public class MainActivity extends AppCompatActivity {

    private CheckBox checkbox1,checkbox2,checkbox3;
    private Button button1;
    private TextView textview;

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

        checkbox1 = this.<CheckBox>findViewById(R.id.checkbox1);
        checkbox2 = this.<CheckBox>findViewById(R.id.checkbox22);
        checkbox3 = this.<CheckBox>findViewById(R.id.checkbox4);
        button1 = this.<Button>findViewById(R.id.buttonid2);
        textview = this.<TextView>findViewById(R.id.textbox);

        button1.setOnClickListener(new View.OnClickListener() {

           @Override            public void onClick(View v) {


                   StringBuffer string = new StringBuffer();

                   if(checkbox1.isChecked()){

                       String value = checkbox1.getText().toString();

                       string.append(value+ " is order "+ " \n");

                   }


                   if (checkbox2.isChecked()){

                       String value2 = checkbox2.getText().toString();

                       string.append(value2+ " is order " + " \n" );

                   }


                   if (checkbox3.isChecked()){

                       String value3 = checkbox3.getText().toString();

                       string.append(value3+ " is order" + " \n");

                   }

                   textview.setText(" "+ string);
                   
            }


        });

    }
}

Produk Kami Lainnya :

Post a Comment

 
ibs(idblogsite)
Copyright © 2014. Background remove
Distributed By Blog Templates | Designed By Gusti Adnyana