background image

11 android ListView 的使用
ListView listView = new ListView(this);
ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String, 
Object>>();
SimpleAdapter adapter = new SimpleAdapter(this,list,R.layout.list,new String[]
{"标题"},new int[]{R.id.TextView01});
listView.setAdapter(adapter);
listView.setOnItemClickListener(this);
然后实现

OnItemClickListener 接口

public void onItemClick(AdapterView<?> parent, View view, int position, long 
id) {}

12 android 更新 ListView
ListView listView = new ListView(this);
ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String, 
Object>>();
SimpleAdapter adapter = new SimpleAdapter(this,list,R.layout.list,new String[]
{"标题"},new int[]{R.id.TextView01});
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();//通知更新 ListView

13 android 创建 LinearLayout
LinearLayout layoutParant = new LinearLayout(this);

14 android 时间设置对话框的使用
DatePickerDialog dlg = new DatePickerDialog(this,this,year,month,day);
dlg.show();
/*year month day   均 为 int 型 , 第 二 个 参 数 为 this 时 , 该 类 需 要 implements 
OnDateSetListener 并重写
public   void   onDateSet(DatePicker   view,   int   year,   int   monthOfYear,int 
dayOfMonth) {}*/

15 android 创建 FrameLayout
FrameLayout layout = new FrameLayout(this);

16 android 触发键盘事件
layout.setOnKeyListener(this);
//需要 implements OnKeyListener 并重写以下方法
public boolean onKey(View v, int keyCode, KeyEvent event) {
return false;//返回是否销毁该事件以接收新的事件,比如返回 true 按下时可以不断执行
这个方法,返回

false 则执行一次。

}

17 android 触发鼠标事件