android的初步学习---拨号器

来源:互联网 发布:mac lol 编辑:程序博客网 时间:2024/05/16 12:00

            1. 安卓的神秘 仅仅是因为 最开始的 工具的安装就把很多人吓跑了,安装之后,发现开发过程和 java的Swing 很像。

           2. 首先 我们简单的介绍 机器创建的 android 项目 会有的几个 文件,

2-1HelloActivity.java自己写的,

2-2R.java----给各种 标签和 文件 提供一个 编码的存在

2-3main.xml---就是 用户点击了 Icon后 会出现的 activity 页面里面 包含了TextView,LinearLayout ,Button ,

      属性设置:  android:layout_width="wrap_content"
          android:layout_height="wrap_content"
   名字 : android:text="@string/button" 或者 android:text="Type:here:" 
         android:id="@+id/button" 把这个 标签 附一个 可以被调用的常量

<pre name="code" class="html"> <TextView        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="@string/sm2"          />             这是给 这个 标签一个 名字    <EditText            android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:minLines="3"        android:id="@+id/sm2" 方便以后的 调用        />        <Button         android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="@string/sm3"        android:id="@+id/sm3"                 />


2-4Strings.xml---就是 把一些 字符串的常量 转化为 R.java中的 编码,方便以后的 引用

<string name="sm3">请输入</string>

   <string name="sm2">拨号</string>

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

3.控制 逻辑的 肯定是自己写的:

HelloActivity.java自己写的,

public class HelloActivity extends Activity {    /** Called when the activity is first created. */    @Override   // 只会 调用一次,    public void onCreate(Bundle savedInstanceState) {        // 必须调用的 ,    super.onCreate(savedInstanceState);                         // 线性布局,    setContentView(R.layout.main);        Button button=(Button)this.findViewById(R.id.button);    button.setOnClickListener(new buttonlister());        }    private final class buttonlister implements View.OnClickListener{        public void onClick(View v){                        //这既是从 R.java中找出来的     EditText mobitext=<span style="background-color: rgb(255, 153, 0);">(EditText)findViewById(R.id.sm2);</span>    String mobs = mobitex<span style="background-color: rgb(255, 153, 0);">t.getText().</span>toString();获取内容        //意图传送方法,寻找匹配的 意图过滤器。    Intent intens=new Intent();                   //<span style="background-color: rgb(255, 0, 0);"> 通过 查源代码查出来的,</span>    intens.setAction("<span style="background-color: rgb(51, 255, 51);">android.intent.action.CALL</span>");    intens.setData(Uri.parse("tel:"+mobs));    startActivity(intens);    }    }        }   
4-1涉及到  权限问题的 还需要把 权限解决

在 manifest.xml文件中实现

<uses-permission android:name="android.permission.SEND_SMS" />


0 0
原创粉丝点击