创建阳光卡屏
点击“光大银行”ListItem,进入一个屏,该屏显示银行卡的账户、余额、公告,并提供充值、消费和交易明细等操作。
?
屏幕的布局代码中xml文件中定义:
整屏主要由3部分组成
(1)账号是2个column构成的TableLayout。
<TableLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent" android:layout_height="wrap_content"android:stretchColumns="1"><TableRow><TextViewandroid:layout_column="1"android:text="账号"android:padding="3dip"style="@style/label"/><TextViewandroid:layout_column="1"android:text="1265 4083 7112 6540 8371"android:padding="3dip"style="@style/label"/></TableRow></TableLayout>
?
(2)余额由3个colun组成的Table布局。
<TableLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent" android:layout_height="wrap_content"android:stretchColumns="1"><TableRow><TextViewandroid:layout_column="1"android:text="余额"android:padding="3dip"style="@style/label"/><TextViewandroid:layout_column="1"android:text="100.00"android:padding="3dip"android:gravity="right"style="@style/balance_text"/><TextViewandroid:layout_column="1"android:text="元"android:padding="3dip"style="@style/label"/></TableRow><View android:layout_height="10dip"android:background="#909090"/></TableLayout>
?
在余额下方有个View是10像素。
(3)最下是个WebView,用于展现html内容:
<WebView android:id="@+id/webview_notice" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" />
?
整个xml文件的布局是LinerLayout:
<?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="fill_parent">...</LinearLayout>
?
WebView的内容定义在EBActivity.java文件中:
public void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.ebbank);mWebView = (WebView) findViewById(R.id.webview_notice);//mWebView.loadUrl("http://www.baidu.com");mWebView.loadData(fmtString(notice1), "text/html", "utf-8");//String summary = "<html><body>You scored <b>192</b> points.</body></html>"; //mWebView.loadData(summary, "text/html", "utf-8"); }private String fmtString(String str){String notice = "";try{notice = URLEncoder.encode(str, "utf-8");}catch(UnsupportedEncodingException ex){}return notice;}private String notice1 = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'/></head>"+ "<body><p align='center'><b>关于关闭电话银行语音系统查询动态密码功能的公告</b></p>"+ "<p align='center'>发布日期:2011-04-25</p>"+ "尊敬的客户:"+ "<br>根据优化电话银行相关服务功能的整体安排,我行决定自4月25日起,在95595电话银行语音系统中,停止受理查询手机动态密码功能。给您带来的不便之处敬请谅解。如有问题,请致电我行24小时服务热线95595。"+ "<br>感谢您长期以来对我行的关注、支持与厚爱!"+ "<br>特此公告。"+ "<br>中国光大银行"+ "<br>2011年4月25日</body></html>";
?菜单也定义在EBActivity.java文件中:
private static final int MENU_CREDIT = Menu.FIRST;private static final int MENU_DEBIT = Menu.FIRST + 1;private static final int MENU_DETAIL = Menu.FIRST + 2;private static final int MENU_FRESH = Menu.FIRST + 3;private static final int MENU_EXIT = Menu.FIRST + 4;@Overridepublic boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, EBActivity.MENU_CREDIT, 0, "充值").setIcon( android.R.drawable.ic_menu_more); menu.add(0, EBActivity.MENU_DEBIT, 0, "消费").setIcon( android.R.drawable.ic_menu_more); menu.add(0, EBActivity.MENU_DETAIL, 0, "交易明细").setIcon( android.R.drawable.ic_menu_more); return true;}@Overridepublic boolean onMenuItemSelected(int featureId, MenuItem item) { switch (item.getItemId()) { case MENU_CREDIT: return true; } return super.onMenuItemSelected(featureId, item);}
?