admin
- 管理员
- 535
- 5885
- 2018-07-20
|
1#
t
T
发表于 2018-08-02 17:01
|只看楼主
- public class DemoActivity extends Activity {
- private Button btn1,btn2;
- private EditText edit1,edit2;
- AlertDialog.Builder builder;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- setContentView(R.layout.demo);
- findView();
- builder = new AlertDialog.Builder(this);
- builder.setTitle("提示");
- /**
- * 小写转大写
- */
- btn1.setOnClickListener(new OnClickListener() {
- @SuppressLint("DefaultLocale")
- @Override
- public void onClick(View v) {
- //获取输入的字符串内容
- String inputData1 = edit1.getText().toString().trim().toUpperCase();
- builder.setMessage(inputData1);
- builder.show();
- }
- });
- /**
- * 大写转小写
- */
- btn2.setOnClickListener(new OnClickListener() {
- @SuppressLint("DefaultLocale")
- @Override
- public void onClick(View v) {
- String inputData2 = edit2.getText().toString().trim().toLowerCase();
- builder.setMessage(inputData2);
- builder.show();
- }
- });
- }
- private void findView() {
- btn1 = (Button) findViewById(R.id.btn1);
- btn2 = (Button) findViewById(R.id.btn2);
- edit1 = (EditText) findViewById(R.id.editText1);
- edit2 = (EditText) findViewById(R.id.editText2);
- }
- }
复制代码
|