android实习程序6——拨号通话
16lz
2021-01-23
拨号通话
ListView GridView AdapterView
在路径android-sdkr16\android-sdkr16\platform-tools确认存在adb.exe 下载youlu_android_1_2_7.youlu.apk 运行cmd d: cd D:\0701\android0701\android-sdkr16\android-sdkr16\platform-tools adb installyoulu_android_1_2_7.youlu.apk 安装adb.exe
D:\0701\android0701\android-sdkr16\android-sdkr16\docs\reference\android\widget 可看android的参考文档
Adapter的4个方法 getCount getView
getItem getItemId
D:\0701\android0701\android-sdkr16\android-sdkr16\tools 点开draw9patch.bat 完成图像的自由拉伸 如:call_log_type_item_bg_a.9.png
常志鹏 18046501727 [email protected] QQ群:326285800
拨号通话: 现完成的是键盘的设置 -------------------------------------------------------------- PhoneManager.java package cpm.tarena.Phone;
import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout;
public class PhoneManagerActivity extends Activity { //ImageButton mImagebutton_1,mImageButton_2,mImageButton_3,mImageButton_4,mImageButton_5,mImageButton_6,mImageButton_7,mImageButton_8,mImageButton_9,mImageButton_10,mImageButton_11,mImageButton_12; ImageButton key_hide; LinearLayout mLinearLayout; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mLinearLayout = (LinearLayout)findViewById(R.id.keyboard_layout); key_hide = (ImageButton) findViewById(R.id.key_hide); key_hide.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v) { // TODO Auto-generated method stub mLinearLayout.setVisibility(View.GONE); } }); } } ------------------------------------------------------------ main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/keyboard_layout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="vertical" android:background="#fcfcfc"> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/keyboard_line_bg" >
<ImageButton android:id="@+id/key_hide" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:background="#0000" android:src="@drawable/keyboard_hide" />
<ImageButton android:id="@+id/key_del" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:background="#0000" android:src="@drawable/keyboard_backspace" />
<Button android:id="@+id/call_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toLeftOf="@id/key_del" android:layout_toRightOf="@id/key_hide" android:background="@drawable/dial_call_bg" android:text="139111111" android:textSize="18sp" android:textColor="#fff" android:ellipsize="start" /> </RelativeLayout>
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >
<ImageButton android:id="@+id/key_1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_1" android:background="@drawable/key_bg_s"/>
<ImageButton android:id="@+id/key_2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_2" android:background="@drawable/key_bg_s"/>
<ImageButton android:id="@+id/key_3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_3" android:background="@drawable/key_bg_s"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >
<ImageButton android:id="@+id/key_4" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_4" android:background="@drawable/key_bg_s"/>
<ImageButton android:id="@+id/key_5" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_5" android:background="@drawable/key_bg_s"/>
<ImageButton android:id="@+id/key_6" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_6" android:background="@drawable/key_bg_s"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >
<ImageButton android:id="@+id/key_7" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_7" android:background="@drawable/key_bg_s"/>
<ImageButton android:id="@+id/key_8" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_8" android:background="@drawable/key_bg_s"/>
<ImageButton android:id="@+id/key_9" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_9" android:background="@drawable/key_bg_s"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >
<ImageButton android:id="@+id/key_jin" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_hash" android:background="@drawable/key_bg_s"/> <ImageButton android:id="@+id/key_0" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_0" android:background="@drawable/key_bg_s"/>
<ImageButton android:id="@+id/key_xin" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_star" android:background="@drawable/key_bg_s"/> </LinearLayout> </LinearLayout>
</RelativeLayout>
----------------------------------------------------- 在res下新建文件夹drawable 在该文件下,新建selector 命名key_bg_s (实现按键时,改变按键的颜色) 实现方法为设置背景时,设置为key_bg_s <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/key_bg_a" android:state_pressed="true"/> <item android:drawable="@drawable/key_bg"/> </selector>
注意:严格的要求在上面 实现的效果为:
ListView GridView AdapterView
在路径android-sdkr16\android-sdkr16\platform-tools确认存在adb.exe 下载youlu_android_1_2_7.youlu.apk 运行cmd d: cd D:\0701\android0701\android-sdkr16\android-sdkr16\platform-tools adb installyoulu_android_1_2_7.youlu.apk 安装adb.exe
D:\0701\android0701\android-sdkr16\android-sdkr16\docs\reference\android\widget 可看android的参考文档
Adapter的4个方法 getCount getView
getItem getItemId
D:\0701\android0701\android-sdkr16\android-sdkr16\tools 点开draw9patch.bat 完成图像的自由拉伸 如:call_log_type_item_bg_a.9.png
常志鹏 18046501727 [email protected] QQ群:326285800
拨号通话: 现完成的是键盘的设置 -------------------------------------------------------------- PhoneManager.java package cpm.tarena.Phone;
import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout;
public class PhoneManagerActivity extends Activity { //ImageButton mImagebutton_1,mImageButton_2,mImageButton_3,mImageButton_4,mImageButton_5,mImageButton_6,mImageButton_7,mImageButton_8,mImageButton_9,mImageButton_10,mImageButton_11,mImageButton_12; ImageButton key_hide; LinearLayout mLinearLayout; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mLinearLayout = (LinearLayout)findViewById(R.id.keyboard_layout); key_hide = (ImageButton) findViewById(R.id.key_hide); key_hide.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v) { // TODO Auto-generated method stub mLinearLayout.setVisibility(View.GONE); } }); } } ------------------------------------------------------------ main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/keyboard_layout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="vertical" android:background="#fcfcfc"> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/keyboard_line_bg" >
<ImageButton android:id="@+id/key_hide" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:background="#0000" android:src="@drawable/keyboard_hide" />
<ImageButton android:id="@+id/key_del" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:background="#0000" android:src="@drawable/keyboard_backspace" />
<Button android:id="@+id/call_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toLeftOf="@id/key_del" android:layout_toRightOf="@id/key_hide" android:background="@drawable/dial_call_bg" android:text="139111111" android:textSize="18sp" android:textColor="#fff" android:ellipsize="start" /> </RelativeLayout>
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >
<ImageButton android:id="@+id/key_1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_1" android:background="@drawable/key_bg_s"/>
<ImageButton android:id="@+id/key_2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_2" android:background="@drawable/key_bg_s"/>
<ImageButton android:id="@+id/key_3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_3" android:background="@drawable/key_bg_s"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >
<ImageButton android:id="@+id/key_4" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_4" android:background="@drawable/key_bg_s"/>
<ImageButton android:id="@+id/key_5" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_5" android:background="@drawable/key_bg_s"/>
<ImageButton android:id="@+id/key_6" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_6" android:background="@drawable/key_bg_s"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >
<ImageButton android:id="@+id/key_7" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_7" android:background="@drawable/key_bg_s"/>
<ImageButton android:id="@+id/key_8" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_8" android:background="@drawable/key_bg_s"/>
<ImageButton android:id="@+id/key_9" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_9" android:background="@drawable/key_bg_s"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >
<ImageButton android:id="@+id/key_jin" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_hash" android:background="@drawable/key_bg_s"/> <ImageButton android:id="@+id/key_0" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_0" android:background="@drawable/key_bg_s"/>
<ImageButton android:id="@+id/key_xin" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/keyboard_star" android:background="@drawable/key_bg_s"/> </LinearLayout> </LinearLayout>
</RelativeLayout>
----------------------------------------------------- 在res下新建文件夹drawable 在该文件下,新建selector 命名key_bg_s (实现按键时,改变按键的颜色) 实现方法为设置背景时,设置为key_bg_s <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/key_bg_a" android:state_pressed="true"/> <item android:drawable="@drawable/key_bg"/> </selector>
注意:严格的要求在上面 实现的效果为:
更多相关文章
- Android Studio引入FFmpeg的方法
- Android TextUtils类常用方法
- Android简单实现启动画面的方法
- Android 判断Root的方法
- android 获取锁屏,解锁的方法
- android中的activity里获得context方法
- android paint设置字体 中文字体 楷体 和自动换行方法(zhuan)