編輯:關於Android編程
1、AlertDialog對話框
AlertDialog.Builder builder=new Builder(HomeActivity.this); builder.setTitle("提示"); builder.setMessage("是否刪除信息?"); builder.setPositiveButton("是",new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { new AsyncTask(){ @Override protected Void doInBackground(Void... params) { //同意則把當前數據寫入請假申請表裡 if(mRejectLeaveInfoDao==null){ mRejectLeaveInfoDao=new RejectLeaveInfosDao(HomeActivity.this); }else{ mRejectLeaveInfoDao.deleteLeaveInfo(tmpInfoReject); } fillDataReject(); return null; } }.execute(); } }); builder.setNegativeButton("否",new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); }
new AsyncTask() { List apps=new ArrayList (); String desc=null; Dialog dialog=new Dialog(KillVirusActivity.this); View viewKilling=View.inflate(KillVirusActivity.this,R.layout.killing_dialog,null); @Override protected void onPreExecute() { mKillVirusResult.setText("正在掃描中,請稍等..."); dialog.setCancelable(false); dialog.setContentView(viewKilling); dialog.show();
3、activity對話框
activity代碼:
package com.example.yqqmobilesafe; import com.example.yqqmobilesafe.db.dao.KeyWordInfoDao; import com.example.yqqmobilesafe.domain.KeyWordInfo; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.Window; import android.view.WindowManager; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class AddKeyWordsInfosDailogActivity extends Activity { protected static final int ADD_KEY_INFO_SCUCESS = 100; private EditText et_key_words_input;//輸入關鍵字 private EditText et_key_words_decribe; private Button mSure;//確定 private Button mCancel;//取消 public AddKeyWordsInfosDailogActivity() { } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //去除title requestWindowFeature(Window.FEATURE_NO_TITLE); //去掉Activity上面的狀態欄 getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN , WindowManager.LayoutParams. FLAG_FULLSCREEN); setContentView(R.layout.add_keyword_info_activity); init(); setListener(); } private void setListener() { mSure.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { KeyWordInfoDao dao=new KeyWordInfoDao(getApplicationContext()); if(et_key_words_input.getText().toString().trim().length()==0){ Toast.makeText(AddKeyWordsInfosDailogActivity.this,"請輸入關鍵字或者取消!",300).show(); return; } if(et_key_words_decribe.getText().toString().trim().length()==0){ Toast.makeText(AddKeyWordsInfosDailogActivity.this,"請輸入關鍵字描述內容或者取消!",300).show(); return; } KeyWordInfo info=new KeyWordInfo(); info.setKey_word_info(et_key_words_input.getText().toString().trim()); info.setKey_word_decribe(et_key_words_decribe.getText().toString().trim()); //把攔截關鍵字加入數據庫 dao.addKeyWordInfos(info); info=null; setResult(ADD_KEY_INFO_SCUCESS, getIntent()); AddKeyWordsInfosDailogActivity.this.finish(); } }); mCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AddKeyWordsInfosDailogActivity.this.finish(); } }); } private void init() { et_key_words_input=(EditText) findViewById(R.id.et_key_words_input); et_key_words_decribe=(EditText) findViewById(R.id.et_key_words_decribe); mSure=(Button) findViewById(R.id.btn_sure); mCancel=(Button) findViewById(R.id.btn_cancel); } @Override protected void onDestroy() { super.onDestroy(); } }
Notification是在你的應用常規界面之外展示的消息。當app讓系統發送一個消息的時候,消息首先以圖表的形式顯示在通知欄。要查看消息的詳情需要進入通知抽屜(noti
本文實例為大家分享了Android仿微信二維碼和條形碼的具體代碼,供大家參考,具體內容如下package your.QRCode.namespace;import jav
簡介:Volley是Google I/O 2013上Google官方發布的一款Android平台上的網絡通信庫。以前的網絡請求,要考慮開啟線程、內存洩漏、性能等等復雜的問
開發中經常需要請求網絡獲取數據,我們在請求網絡到得到數據時當中需要等待一些時間,為了增加用戶體驗,我們一般會用一個Dialog來提示用戶我們在加載網絡數據。今天我們來實現