`
文章列表
一、三种类型的进度条 progress_bar.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height= ...
一、DatePicker与TimePicker动态输入时间和日期 private int mYear; private int mMonth; private int mDay; private int mHour; private int mMinute; TextView tv; TimePicker tp; DatePicker dp; public void onCreate(Bundle savedInstanceState) { Calendar c = Calendar.get ...
一、AnalogClock时钟显示时间 protected static final int GUINOTIFIER = 0x1234; private TextView mTextView; public AnalogClock mAnalogClock; public Calendar mCalendar; public int mMinutes; public int mHour; public Handler mHandler; private Thread mClockThread; public void onCreate ...
一、AutoCompleteTextView的应用   private static final String[] autoStr = new String[] { "abb", "abc", "abcd", "abcde" }; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* 载入main.xml Layout */ setContentView(R ...
一、Toast自定义显示位置效果   Toast toast = Toast.makeText(getApplicationContext(), "自定义位置Toast", Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show();     二、Toast带图片   Toast toast = Toast.makeText(getApplicationContext(),"带图片的Toast", Toast.LENGTH_L ...
一、CheckBox多选项的创建   mCheckBox1 = (CheckBox) findViewById(R.id.myCheckBox1); /* 设定OnCheckedChangeListener给三个CheckBox对象 */ mCheckBox1.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener(){ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { i ...
一、RadioBox单选框的使用   public RadioGroup mRadioGroup1; public RadioButton mRadio1, mRadio2; public Button button1; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout. ...
主程序代码:   private SimpleAdapter listItemAdapter; // ListView的适配器 private ArrayList<HashMap<String, Object>> listItem; // ListView的数据源,这里是一个HashMap的列表 private IphoneListView myList; // ListView控件 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstance ...
PopupWindow其实类似于一个不能动的Widget(仅从显示效果来说!),它是浮在别的窗口之上的.。   import android.view.ViewGroup.LayoutParams; handler = new Handler(){ public void handleMessage(Message msg){ switch(msg.what){ case 1: Context mContext = Main.this; LayoutInflater mLayoutInflater = (LayoutInflater) ...
一、Spinner自定义下拉菜单   private Spinner mySpinner; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.spinner); final String[] countriesStr = { "台北市", "台北县", "台中市", "高雄市" }; ArrayAdapter& ...
一、自定义背景的Button   android:background="@drawable/btn"  res/drawable/btn.xml   <?xml version="1.0" encoding="UTF-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="false" ...
一、Gallery的拖动图片特效   public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.koo); Gallery gallery = (Gallery)findViewById(R.id.gallery1);gallery.setAdapter(new ImageAdapter(this)); } public class ImageAdapter extends BaseAdapt ...
一、OptionsMenu的创建   private final int MENU_ABOUT = Menu.FIRST; private final int MENU_EXIT = Menu.FIRST + 1; public boolean onCreateOptionsMenu(Menu menu){ String menuLabels[] = {"关于" , "退出"}; for( int order = 0 ; order < menuLabels.length ; order++ ){ menu.add( ...
一、与线程的结合   final CharSequence strDialogTitle = getString(R.string.str_dialog_title); final CharSequence strDialogBody = getString(R.string.str_dialog_body); // 显示Progress对话框 myDialog = ProgressDialog.show(EX03_18.this, strDialogTitle, strDialogBody, true); new Thread() { ...
一、打勾显示输入的密码   private EditText et; private CheckBox cb; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.password); et = (EditText)findViewById(R.id.editText1); cb = (CheckBox)findViewById(R.id.checkBox1); cb ...
Global site tag (gtag.js) - Google Analytics