Advertisement
delvinkrasniqi

Radiobuton - ngjyra

Nov 28th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. package com.example.mbledhja;
  2.  
  3. import androidx.appcompat.app.AppCompatActivity;
  4.  
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.widget.Button;
  8. import android.widget.EditText;
  9. import android.widget.RadioButton;
  10. import android.widget.TextView;
  11.  
  12. public class MainActivity extends AppCompatActivity {
  13. RadioButton kuq , blu , verdhe;
  14. TextView txtView;
  15. Button button;
  16.  
  17. @Override
  18. protected void onCreate(Bundle savedInstanceState) {
  19. super.onCreate(savedInstanceState);
  20. setContentView(R.layout.activity_main);
  21.  
  22. kuq=(RadioButton)findViewById(R.id.radioButton);
  23. blu=(RadioButton)findViewById(R.id.radioButton2);
  24. verdhe=(RadioButton)findViewById(R.id.radioButton3);
  25.  
  26. txtView=(TextView)findViewById(R.id.textView4);
  27. button=(Button)findViewById(R.id.button2);
  28.  
  29. button.setOnClickListener(new View.OnClickListener() {
  30. @Override
  31. public void onClick(View v) {
  32. if(kuq.isChecked()){
  33. txtView.setText("Keni zgjedhur ngjyre te kuqe");
  34. }
  35. else if(blu.isChecked()){
  36. txtView.setText("Keni zgjedhur ngjyre blu");
  37. }
  38. else if (verdhe.isChecked()){
  39. txtView.setText("Keni zgjedhur ngjyre verdh");
  40. }
  41. else{
  42. txtView.setText("Ju skeni sgjedhur asnje ngjyre");
  43. }
  44. }
  45. });
  46.  
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement