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;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Android 简单的机票预订系统源码.zip项目安卓应用源码下载Android 简单的机票预订系统源码.zip项目安卓应用源码下载 1.适合学生毕业设计研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考
资源推荐
资源详情
资源评论
收起资源包目录
Android 简单的机票预订系统源码.zip (75个子文件)
Android 简单的机票预订系统源码
Android 简单的机票预订系统源码
1-1209161450040-L.png 74KB
1_120916145144_1.png 55KB
Android 简单的机票预订系统源码
.project 849B
bin
res
drawable-ldpi
blue_button.9.png 2KB
drawable-hdpi
drawable-mdpi
settings.png 4KB
wine.png 5KB
ticketmanager.png 3KB
background.png 15KB
question.png 1KB
topbg.png 194B
plane.png 5KB
about.png 4KB
glass.png 3KB
dingdanmanager.png 4KB
resources.ap_ 67KB
classes
com
airport
bean
SingleBean.class 2KB
xml
SingleXML.class 3KB
main
CheckAirportTabActivity$6.class 2KB
R$string.class 421B
FillInformation.class 522B
R$layout.class 582B
CheckAirportTabActivity$leaveDateClick.class 837B
MainActivity.class 2KB
R$drawable.class 750B
CheckAirportTabActivity$1.class 2KB
CheckAirportTabActivity$2.class 2KB
R.class 517B
CheckAirportTabActivity.class 6KB
SingleListActivity.class 6KB
CheckAirportTabActivity$3.class 2KB
CheckAirportTabActivity$4.class 1KB
R$attr.class 334B
MainActivity$1.class 2KB
CheckAirportTabActivity$5.class 1KB
CheckAirportTabActivity$returnDateClick.class 840B
MainActivity$ImageAdapter.class 2KB
R$id.class 2KB
tool
DBHelper.class 3KB
lib
classes.dex 161KB
AirportTicket.apk 274KB
proguard.cfg 1KB
AndroidManifest.xml 1003B
src
com
airport
bean
SingleBean.java 1KB
xml
SingleXML.java 2KB
main
CheckAirportTabActivity.java 8KB
SingleListActivity.java 4KB
MainActivity.java 3KB
FillInformation.java 301B
tool
DBHelper.java 2KB
lib
ksoap2-android-assembly-2.3-jar-with-dependencies.jar 138KB
project.properties 360B
res
values
strings.xml 201B
layout
single_city_item.xml 2KB
single_city.xml 3KB
main.xml 669B
main_textview.xml 637B
check_airport_tab.xml 7KB
information_spell.xml 4KB
drawable-ldpi
blue_button.9.png 3KB
drawable-hdpi
drawable-mdpi
settings.png 6KB
wine.png 7KB
ticketmanager.png 6KB
background.png 15KB
question.png 1KB
topbg.png 317B
plane.png 7KB
about.png 4KB
airplane.jpg 5KB
glass.png 3KB
dingdanmanager.png 8KB
.classpath 364B
gen
com
airport
main
R.java 4KB
assets
city.xml 22KB
single.xml 1KB
1_120916145145_2.png 58KB
共 75 条
- 1
资源评论
yxkfw
- 粉丝: 81
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功