package com.airport.main;
import java.util.Calendar;
import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.app.Dialog;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TabHost;
public class CheckAirportTabActivity extends TabActivity {
private Spinner gospinner, setofffspinner, airportcompany;//出发,目的的下拉列表,航空公司
private Button selectbtn;//查询按钮
private String leaveCity, arriveCity, leavedate;//出发城市,目的城市,日期的String类型,用于传数据
private String[] city = { "上海", "北京", "广州", "大连", "沈阳", "福州" ,"南京"};
private String[] company = { "中国航空", "东方航空", "上海航空", "海南航空", "南方航空",
"厦门航空", "深圳航空" };
private EditText leaveDateEdt, returnBackDateEdt;//出发城市,返回城市编辑框
private Button leaveDateBtn, returnDateBtn;
private int m_year, m_month, m_day;
private Calendar c;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.check_airport_tab);
TabHost th = getTabHost();
th.addTab(th.newTabSpec("single").setIndicator("单程")
.setContent(R.id.tab1));
th.addTab(th.newTabSpec("return").setIndicator("返程")
.setContent(R.id.tab2));
gospinner = (Spinner) findViewById(R.id.go_selectcity);
setofffspinner = (Spinner) findViewById(R.id.setoffcity);
airportcompany = (Spinner) findViewById(R.id.airport_company);
leaveDateEdt = (EditText) findViewById(R.id.setoff_date);
leaveDateBtn = (Button) findViewById(R.id.setoffdate_btn);
returnDateBtn = (Button) findViewById(R.id.return_date_btn);
returnBackDateEdt = (EditText) findViewById(R.id.setoff_date);
selectbtn = (Button) findViewById(R.id.select_btn);
c = Calendar.getInstance();//获取日历的实例
m_year = c.get(Calendar.YEAR);//年
m_month = c.get(Calendar.MONTH);//月
m_day = c.get(Calendar.DAY_OF_MONTH);//日
// CreateDataBase();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, company);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
airportcompany.setAdapter(adapter);//将航空公司数组装入适配器
ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, city);
adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
gospinner.setAdapter(adapter1);
setofffspinner.setAdapter(adapter1);
leaveDateBtn.setOnClickListener(new leaveDateClick());
returnDateBtn.setOnClickListener(new returnDateClick());
gospinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
setofffspinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
//查询按钮事件
selectbtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(CheckAirportTabActivity.this,
SingleListActivity.class);
leaveCity = gospinner.getSelectedItem().toString();//获取出发城市选择的选项并转换成文字
arriveCity = setofffspinner.getSelectedItem().toString();//同理
leavedate = leaveDateEdt.getText().toString();//同理
Bundle bundle = new Bundle();//Bundle存取数据,如出发城市,到达城市。出发日期等
bundle.putString("leaveCity", leaveCity);
bundle.putString("arriveCity", arriveCity);
bundle.putString("leavedate", leavedate);
intent.putExtras(bundle);//向查询界面传送数据
startActivity(intent);
finish();
}
});
}
class leaveDateClick implements OnClickListener {
@Override
public void onClick(View v) {
showDialog(0);
}
}
class returnDateClick implements OnClickListener {
@Override
public void onClick(View v) {
showDialog(1);
}
}
/*
* private void CreateDataBase() { DBHelper helper = new
* DBHelper(CheckAirportTabActivity.this, "cities_db"); Cursor cursor =
* helper.query("cities", new String[] { "_id", "cityname" }, null, null,
* null, null, null); if (cursor.getCount() == 0) {
* helper.exeecSQL("insert into cities(cityname) values('上海')");
* helper.exeecSQL("insert into cities(cityname) values('北京')");
* helper.exeecSQL("insert into cities(cityname) values('广州')");
* helper.exeecSQL("insert into cities(cityname) values('大连')");
* helper.exeecSQL("insert into cities(cityname) values('沈阳')");
* helper.exeecSQL("insert into cities(cityname) values('重庆')");
* helper.exeecSQL("insert into cities(cityname) values('福州')");
* helper.exeecSQL("insert into cities(cityname) values('南昌')");
* helper.exeecSQL("insert into cities(cityname) values('鞍山')");
* helper.exeecSQL("insert into cities(cityname) values('昆明')");
* helper.exeecSQL("insert into cities(cityname) values('武汉')");
* helper.exeecSQL("insert into cities(cityname) values('海口')");
* helper.exeecSQL("insert into cities(cityname) values('重庆')");
* helper.exeecSQL("insert into cities(cityname) values('长沙')");
* helper.exeecSQL("insert into cities(cityname) values('赤峰')");
*
* } SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
* android.R.layout.simple_spinner_item, cursor, new String[] { "cityname"
* }, new int[] { android.R.id.text1 });
* adapter.setDropDownViewResource(android
* .R.layout.simple_spinner_dropdown_item); gospinner.setAdapter(adapter);
* setofffspinner.setAdapter(adapter); }
*/
@Override
protected Dialog onCreateDialog(int id) {
if (id == 0) {
return new DatePickerDialog(this, l1, m_year, m_month, m_day);
} else if (id == 1) {
return new DatePickerDialog(this, l2, m_year, m_month, m_day);
} else if (id == 2) {
return new DatePickerDialog(this, l3, m_year, m_month, m_day);
}
return null;
}
private OnDateSetListener l1 = new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
m_year = year;
m_month = monthOfYear;
m_day = dayOfMonth;
leaveDateEdt.setText(m_year + "-" + (m_month + 1) + "-" + m_day);
}
};
private OnDateSetListener l2 = new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
m_year = year;
m_month = monthOfYear;
m_day = dayOfMonth;
returnBackDateEdt.setText(m_year + "-" + (m_month + 1) + "-"
+ m_day);
}
};
private OnDateSetListener l3 = new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
m_year = year;
m_month = monthOfYear;
m_day = dayOfMonth;
returnBackDateEdt.setText(m_year + "-" + (m_month + 1) + "-"
+ m_day);
}
};
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode==KeyEvent.KEYCODE_BACK) {
System.exit(0);
}
return true;
}
}
yxkfw
- 粉丝: 82
- 资源: 2万+
最新资源
- 基于 AT89C51 的电梯控制系统嵌入式系统实验详细文档+全部资料+高分项目+源码.zip
- 本科毕设-基于嵌入式arm的人脸识别智能门禁,包括代码、电路图,具体流程详细文档+全部资料+高分项目+源码.zip
- 毕设-基于WIFI车间设备监测与控制系统的研究)的主程序,采用Qt框架编写,以嵌入式ARM Linux系统作为软件运行平台详细文档+全部资料+高分项目+源码.zip
- 基于 react + koa, 开箱即用的 Material Design 风格博客系统..详细文档+全部资料+高分项目+源码.zip
- Project2.zip
- 用c++语言实现的各种算法源代码.zip
- 基于 u8g2 的单色 OLED 菜单 UI 框架。MiaoUI使用 C 语言实现,,适用于具有小型OLED屏幕的嵌入式设备。详细文档+全部资料+高分项目+源码
- 基于ARM的嵌入式小系统,在系统挂掉之后,提取现场的dump信息详细文档+全部资料+高分项目+源码.zip
- 基于Android基于WebView的嵌入式Youtube视频播放器,可识别多种Youtube分享视频的url详细文档+全部资料+高分项目+源码.zip
- 基于ARM-Linux的嵌入式视觉移动追踪系统,并通过Android APP进行无线控制详细文档+全部资料+高分项目+源码.zip
- 基于C++11,协作式调度物联网嵌入式操作系统详细文档+全部资料+高分项目+源码.zip
- 基于ARM架构Cortex-A8的IC卡嵌入式刷卡考勤系统详细文档+全部资料+高分项目+源码.zip
- 基于cc2530的嵌入式详细文档+全部资料+高分项目+源码.zip
- 基于ChatGPT的智能音箱嵌入式课程设计详细文档+全部资料+高分项目+源码.zip
- 基于Cortex-M内核的嵌入式操作系统,针对新手设计,简单易懂详细文档+全部资料+高分项目+源码.zip
- 基于contiki与ucGUI的嵌入式微操作系统例程详细文档+全部资料+高分项目+源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈