首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

除此以外一种继承 Dialog的方法以及发动线程

2012-08-27 
另外一种继承 Dialog的方法以及发动线程public class SettingsDialog extends Dialog implements android.

另外一种继承 Dialog的方法以及发动线程

public class SettingsDialog extends Dialog implements android.view.View.OnClickListener {
???

??? public SettingsDialog(XMPPClient xmppClient) {
??????? super(xmppClient);
?????????? }

??? protected void onStart() {
??????? super.onStart();
??????? setContentView(R.layout.settings);
??????? getWindow().setFlags(4, 4);
??????? setTitle("XMPP Settings");
??????? Button ok = (Button) findViewById(R.id.ok);
??????? ok.setOnClickListener(this);
??? }

??? public void onClick(View v) {
??????? String host = getText(R.id.host);
??????? String port = getText(R.id.port);
??????? String service = getText(R.id.service);
??????? String username = getText(R.id.userid);
??????? String password = getText(R.id.password);

????????????????????????? dismiss();
??? }

??? private String getText(int id) {
??????? EditText widget = (EditText) this.findViewById(id);
??????? return widget.getText().toString();
??? }
}

?

使用

?setup.setOnClickListener(new View.OnClickListener() {
??????????? public void onClick(View view) {
??????????????? mHandler.post(new Runnable() {
??????????????????? public void run() {
??????????????????????? mDialog.show();
??????????????????? }
??????????????? });
??????????? }
??????? });

热点排行