編輯:初級開發
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.VIEw;
import android.view.VIEw.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageVIEw;
import android.widget.Toast;
public class Demo1 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
Button b1;
super.onCreate(savedInstanceState);
setContentVIEw(R.layout.main);
b1=(Button)findVIEwById(R.id.b1);
// new AlertDialog.Builder(Demo1.this)
// .setTitle("請選擇")
// .setIcon(android.R.drawable.ic_dialog_info)
// .setSingleChoiceItems(new String[] {"選項1","選項2","選項3","選項4"}, 0,
// new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int which) {
// dialog.dismiss();
// }
// }
// )
// .setNegativeButton("取消", null)
// .show();
// new AlertDialog.Builder(Demo1.this)
// .setTitle("請輸入")
// .setIcon(android.R.drawable.ic_dialog_info)
// .setVIEw(new EditText(Demo1.this))
// .setPositiveButton("確定", null)
// .setNegativeButton("取消", null)
// .show();
ImageView img = new ImageVIEw(Demo1.this);
img.setImageResource(R.drawable.icon);
new AlertDialog.Builder(Demo1.this)
.setTitle("多選框")
// .setItems(new String[] {"列表項1","列表項2","列表項3"}, null)
// .setMultiChoiceItems(new String[] {"選項1","選項2","選項3","選項4"}, null, null)
.setVIEw(img)
.setIcon(android.R.drawable.ic_lock_silent_mode_off)
.setPositiveButton("確定", null)
.setNegativeButton("取消", null)
.show();
b1.setOnClickListener(new OnclickListener());
}
class OnclickListener implements OnClickListener{
public void onClick(VIEw v) {
// TODO Auto-generated method stub
AlertDialog.Builder ab = new AlertDialog.Builder(Demo1.this);
ab.setTitle("請選擇");
ab.setIcon(android.R.drawable.ic_dialog_info);
ab.setSingleChoiceItems(new String[] {"選項1","選項2","選項3","選項4"}, 0,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}
);
ab.setNegativeButton("取消", null);
ab.show();
}
}
}
HTC Hero作為一款硬件配置強悍的智能手機,對不同版本的android系統兼容性非常好,曾有用戶將HTC新機Espresso內的2.1版android系統和最新的S
下面展示一段在android1.5上讀取手機通訊錄的代碼1 //鏈接通訊錄數據庫 2 ContentResolver content = getContentResol
最近逛其它論壇的時候看到有這樣一個問題,需要界面加載完成後自動彈出軟鍵盤。開始我認為沒有那麼麻煩,最後自己做了一個小例子,還真不好搞定,直到昨天再想這個的問題的時候,想
Google近期開始打擊盜版Android軟件,為開發者提供了 License Verification Library (LVL) 方式來防止Android軟件被盜版