实验三-查找与排序-5(选做,加分) 补做

题目

编写Android程序对各种查找与排序算法进行测试
提交运行结果截图
推送代码到码云

解答

微信图片_20171209095009.png

微信图片_20171209095014.png

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity{

    EditText editText;
    TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        editText = (EditText)findViewById(R.id.text);
        Button button1 = (Button) findViewById(R.id.search);
        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String data = editText.getText().toString();
                Intent intent = new Intent(MainActivity.this, Search.class);
                intent.putExtra("extra_data", data);
                startActivity(intent);
            }
        });
        Button button2 = (Button)findViewById(R.id.sort);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String data = editText.getText().toString();
                Intent intent = new Intent(MainActivity.this, Search.class);
                intent.putExtra("extra_data", data);
                startActivity(intent);
            }
        });
    }
}


posted @ 2017-12-09 09:56  20162308马平川  阅读(138)  评论(0编辑  收藏  举报