Discuz!NT|BBS|论坛

注册

 

发新话题 回复该主题

字符串大小写转化 [复制链接]

1#
  1. public class DemoActivity extends Activity {

  2. private Button btn1,btn2;
  3. private EditText edit1,edit2;

  4. AlertDialog.Builder builder;

  5. @Override
  6. protected void onCreate(Bundle savedInstanceState) {
  7. super.onCreate(savedInstanceState);
  8. requestWindowFeature(Window.FEATURE_NO_TITLE);
  9. setContentView(R.layout.demo);

  10. findView();

  11. builder = new AlertDialog.Builder(this);
  12. builder.setTitle("提示");
  13. /**
  14. * 小写转大写
  15. */
  16. btn1.setOnClickListener(new OnClickListener() {


  17. @SuppressLint("DefaultLocale")
  18. @Override
  19. public void onClick(View v) {
  20. //获取输入的字符串内容
  21. String inputData1 = edit1.getText().toString().trim().toUpperCase();
  22. builder.setMessage(inputData1);
  23. builder.show();


  24. }
  25. });

  26. /**
  27. * 大写转小写
  28. */
  29. btn2.setOnClickListener(new OnClickListener() {


  30. @SuppressLint("DefaultLocale")
  31. @Override
  32. public void onClick(View v) {
  33. String inputData2 = edit2.getText().toString().trim().toLowerCase();
  34. builder.setMessage(inputData2);
  35. builder.show();

  36. }
  37. });



  38. }

  39. private void findView() {
  40. btn1 = (Button) findViewById(R.id.btn1);
  41. btn2 = (Button) findViewById(R.id.btn2);
  42. edit1 = (EditText) findViewById(R.id.editText1);
  43. edit2 = (EditText) findViewById(R.id.editText2);

  44. }

  45. }  
复制代码
分享 转发
TOP
发新话题 回复该主题