Advertisement
Guest User

Palindrom_lepszy

a guest
Jan 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. package com.example.paul.palindrom_2;
  2.  
  3. import android.support.v7.app.AppCompatActivity;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.widget.EditText;
  7. import android.widget.TextView;
  8.  
  9. public class MainActivity extends AppCompatActivity {
  10.  
  11. EditText editText;
  12. TextView textView;
  13.  
  14.  
  15. @Override
  16. protected void onCreate(Bundle savedInstanceState) {
  17. super.onCreate(savedInstanceState);
  18. setContentView(R.layout.activity_main);
  19. editText = (EditText) findViewById(R.id.editText);
  20. textView = (TextView) findViewById(R.id.textView);
  21. }
  22.  
  23. public void palindromOnClick(View view){
  24. String tempText;
  25. tempText = editText.getText().toString().toLowerCase();
  26. StringBuilder stringBuilder = new StringBuilder();
  27. stringBuilder.append(tempText).reverse();
  28. if(stringBuilder.toString().equals(tempText))
  29. textView.setText("To jest palindrom");
  30. else
  31. textView.setText("To nie palindrom");
  32. }
  33.  
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement