随笔分类 -  手机编程代码记录

手机编程虽然简单,但是也是需要代码记录一下的
摘要:import android.R.string;import android.location.GpsStatus.Listener;import android.net.Uri;import android.os.Bundle;import android.app.Activity;import android.text.Spannable;import android.text.SpannableStringBuilder;import android.text.style.ForegroundColorSpan;import android.util.Log;import android 阅读全文
posted @ 2013-06-08 16:01 zhang1107 阅读(323) 评论(0) 推荐(0)
摘要:新建一个用于service的class,Superclass属性设置为Service-android.app, 命名为Pservice在其中复写方法,代码如下:@Override public void onCreate() { // TODO Auto-generated method stub Log.i(TAG, "EXampleService--->onCreate"); super.onCreate(); } @Override public void onDestroy() { // TODO Auto... 阅读全文
posted @ 2013-06-08 15:27 zhang1107 阅读(181) 评论(0) 推荐(0)
摘要:创建Source Folder用于打包test的包:New->Package新建一个包用于存放debug的class,在这个报下面New->class创建一个class对于class创建:New->JUnit Test Case, Superclass(browse)->androidTestCase选择测试的方法debug不是太会做, 以后做项目慢慢补充。 阅读全文
posted @ 2013-06-08 14:39 zhang1107 阅读(133) 评论(0) 推荐(0)
摘要:Table.Layout属于一种表格布局:Table.Layout属于一种表格布局:android:stretchColumns="1" //自动填补空白android:shrinkColumns="2" //当一个button的内容超出一行的长度自动换行android:layout_column="2" //指定控件的列号android:layout_span="2" //合并两列一个例子:TableLayout类似与LinearLayout 的控件配置<TableLayout xmlns:android= 阅读全文
posted @ 2013-06-08 11:09 zhang1107 阅读(153) 评论(0) 推荐(0)
摘要:RelativeLayout的一个简单的列子:<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/txt01" android:layout_width="wrap_content" 阅读全文
posted @ 2013-06-08 00:08 zhang1107 阅读(157) 评论(0) 推荐(0)
摘要:AbsoluteLayout(不推荐使用): <TextView android:layout_x="10px" android:layout_y="10px" android:background="#00FF00" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello" /> View Code FrameLayo 阅读全文
posted @ 2013-06-07 23:50 zhang1107 阅读(358) 评论(0) 推荐(0)
摘要:<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" <!--垂直布局--> > <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayou 阅读全文
posted @ 2013-06-07 23:03 zhang1107 阅读(158) 评论(0) 推荐(0)
摘要:Log类对错误的排查:示例代码private final static String TAG = "MainActivity"; //宏定义Log.i(TAG,"MainActivity---->OnCreate"); //排错View CodeActivity 的save保存宏定义: private static final String CONTENT = "content";OnCreate中添加EditText的判断条件:txt=(EditText)findViewById(R.id.txt); if(null==sav 阅读全文
posted @ 2013-06-03 14:15 zhang1107 阅读(134) 评论(0) 推荐(0)
摘要:发送短信的代码:在MainActivity.java中添加Btn=(Button)findViewById(R.id.mainBtn); Btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent=new Intent(); ... 阅读全文
posted @ 2013-06-03 10:39 zhang1107 阅读(125) 评论(0) 推荐(0)
摘要://Ctrl+D 删除//RGB颜色对照 "#000000"->black "#00FF00"->greenandroid:inputType="number" //限制输入的是数字android:hint="I&apos;m EditText" //显示提示信息//在drawable-mdpi中导入png格式的图片,图片名称为baiandroid:drawableLeft="@drawable/bai" //引用图片//在drawable-mdpi中创建xml文件shape 阅读全文
posted @ 2013-05-22 18:57 zhang1107 阅读(108) 评论(0) 推荐(0)
摘要://Alt + ?实现代码的自动补全//res/values/strings.xml 目录下面实现类似于c++的宏定义<string name="hello">Hello Notebook!!</string><TextView android:text="@string/hello" />//显示的是调用的内容android:textSize="20sp" //字体大小用sp作为单位,宽度,高度用dpandroid:textColor="#00FF00"//设置字体颜色为绿色a 阅读全文
posted @ 2013-05-22 14:23 zhang1107 阅读(117) 评论(0) 推荐(0)