WEB开发网
开发学院手机开发Android 开发 Android 之LinearLayout+EditText+Button+AlertDi... 阅读

Android 之LinearLayout+EditText+Button+AlertDialog

 2010-08-14 00:43:00 来源:WEB开发网   
核心提示:import android.widget.EditText; 7 8 public class practice extends Activity { 9 Button btnShow;10 Button btnClear;11 EditText text;12 /** Called when the activit
import android.widget.EditText; 7 8 public class practice extends Activity { 9 Button btnShow;10 Button btnClear;11 EditText text;12 /** Called when the activity is first created. */13 @Override14 public void onCreate(Bundle savedInstanceState) {15 super.onCreate(savedInstanceState);16 setContentView(R.layout.main);17 18 btnShow = (Button)findViewById(R.id.btnShow);19 btnClear = (Button)findViewById(R.id.btnClear);20 text = (EditText)findViewById(R.id.text);21 22 btnShow.setOnClickListener(new View.OnClickListener() {23 24 @Override25 public void onClick(View v) {26 // TODO Auto-generated method stub27 new AlertDialog.Builder(practice.this)28 .setTitle("Infomation")29 .setIcon(android.R.drawable.ic_dialog_dialer)30 .setMessage(text.getText())31 .show();32 }33 });34 35 btnClear.setOnClickListener(new View.OnClickListener() {36 37 @Override38 public void onClick(View v) {39 // TODO Auto-generated method stub40 text.setText("");41 }42 });43 }44 }

上一页  1 2 

Tags:Android LinearLayout EditText

编辑录入:coldstar [复制链接] [打 印]
赞助商链接