2.下拉框事件
sp.setOnItemSelectedListener(new OnItemSelectedListener() {
//一级联
public void onItemSelected(AdapterView<?> arg0, View view,
int position, long id) {
TextView tView = (TextView) view;
string = tView.getText().toString();
tv.setText(string);
if (string.equals("湖南")) {
hnAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sp2.setAdapter(hnAdapter);
} else if (string.equals("湖北")) {
hbAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sp2.setAdapter(hbAdapter);
} else if (string.equals("广东")) {
gdAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sp2.setAdapter(gdAdapter);
}
}
3.日期时间事件
tp.setOnTimeChangedListener(new OnTimeChangedListener(){
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
// TODO Auto-generated method stub
tView.setText(hourOfDay+":"+minute);
}});
dp.init(2017 , 06 , 19, new DatePicker.OnDateChangedListener() {
public void onDateChanged(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
tView.setText(" "+year+" "+(monthOfYear+1)+" "+dayOfMonth);
}
});
4.按钮选项改变事件
rg.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
rb=(RadioButton) findViewById(checkedId);
String txt=rb.getText().toString();
tv.setText(txt);
}
});