Guest User

Untitled

a guest
Jan 12th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. How do I make a radio button selection convert to a string and put it into EditText?
  2. public class HttpLogin extends Activity {
  3. private Button login;
  4. private EditText company, username, password;
  5. private int radioCheckedId;
  6.  
  7. @Override
  8. public void onCreate(Bundle savedInstanceState) {
  9. super.onCreate(savedInstanceState);
  10. setContentView(R.layout.activity_main);
  11.  
  12. login = (Button) findViewById(R.id.button1);
  13. RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radioCompany);
  14. radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener()
  15. {
  16. public void onCheckedChanged(RadioGroup group, int checkedId) {
  17. radioCheckedId = checkedId;
  18. if(radioCheckedId==1){
  19. company=R.string.a_e;
  20. }
  21. if(radioCheckedId==2){
  22. company=R.string.stat_o;
  23. }
  24. else{
  25. Toast.makeText(getApplicationContext(), "Please choose a company.",
  26. Toast.LENGTH_LONG).show();
  27. }
  28.  
  29. }
  30. });
  31. username = (EditText) findViewById(R.id.editText1);
  32. password = (EditText) findViewById(R.id.editText2);
  33.  
  34. login.setOnClickListener(new OnClickListener() {
  35.  
  36. public void onClick(View v) {
  37.  
  38. String mCompany = company.getText().toString();
  39. String mUsername = username.getText().toString();
  40. String mPassword = password.getText().toString();
  41.  
  42. tryLogin(mCompany, mUsername, mPassword);
  43. }
  44. });
  45. }
Add Comment
Please, Sign In to add comment