android實習程序6——撥號通話

撥號通話

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 install youlu_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
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>

注意:嚴格的要求在上面
實現的效果爲:
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章