package a123456.threaddemo; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt = (Button) findViewById(R.id.button1); bt.setOnClickListener(new MyClickListener()); } class MyClickListener implements View.OnClickListener //alt+enter { public void onClick(View v) { Thread thread= new Thread(new Runnable() { @Override public void run() { //Toast.makeText(MainActivity.this,"hello",Toast.LENGTH_SHORT).show(); } }); runOnUiThread(thread); } } }
android stduio线程
最新推荐文章于 2024-03-01 14:49:53 发布