日期:2014-05-16 浏览次数:20375 次
在前面的几章里面写了显示、键盘、拨号、删除功能,这里我将他们进行组合,形成一个拨号键盘全部功能。首先是布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".SipHome" > <RelativeLayout android:id="@+id/topField" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_marginBottom="0dip" android:layout_weight="@integer/dialpad_layout_weight_digits" android:background="@drawable/dialpad_background" android:orientation="horizontal" android:padding="0dip" > <com.jwzhangjie.pjsip.ui.dialpad.DigitsEditText android:id="@+id/digitsText" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/transparent" android:contentDescription="@string/description_digits_edittext" android:gravity="center" android:imeActionLabel="@string/call" android:imeOptions="actionGo" android:nextFocusRight="@+id/accountChooserButton" android:textAppearance="@style/DialtactsDigitsTextAppearance" android:textColor="@android:color/white" /> </RelativeLayout> <include layout="@layout/dialpad_compose_3x5" /> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <merge xmlns:android="http://schemas.android.com/apk/res/android" > <com.jwzhangjie.pjsip.widgets.Dialpad android:id="@+id/dialPad" android:layout_width="match_parent" android:layout_height="0dip" android:layout_gravity="center_horizontal" android:layout_weight="@integer/dialpad_layout_weight_dialpad" android:background="@drawable/dialpad_background" android:paddingBottom="10dip" android:paddingLeft="5dip" android:paddingRight="5dip" /> <View android:layout_width="match_parent" android:layout_height="@dimen/dialpad_vertical_margin" android:background="#66000000" /> <com.jwzhangjie.pjsip.widgets.DialerCallBar android:id="@+id/dialerCallBar" android:layout_width="match_parent" android:layout_height="0dip" android:layout_gravity="center_horizontal" android:layout_weight="@integer/dialpad_layout_weight_additional_buttons" android:background="@drawable/dialpad_background" android:orientation="horizontal" /> </merge>代码如下:
package com.jwzhangjie.pjsip.ui; import com.jwzhangjie.pjsip.R; import com.jwzhangjie.pjsip.ui.dialpad.DigitsEditText; import com.jwzhangjie.pjsip.widgets.DialerCallBar; import com.jwzhangjie.pjsip.widgets.DialerCallBar.OnDialActionListener; import com.jwzhangjie.pjsip.widgets.Dialpad; import com.jwzhangjie.pjsip.widgets.Dialpad.OnDialKeyListener; import android.os.Bundle; import android.text.Editable; import android.text.Selection; import android.text.TextWatcher; import android.text.method.DialerKeyListener; import android.view.KeyEvent; import android.view.Menu; import android.view.View; import android.view.View.OnClickList