摘要: android发送HTTP请求代码,以GET方式发送。String uriAPI = “http://www.getideas.cn/service/service.do?me=1″; HttpGet httpRequest = new HttpGet(uriAPI); try { HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequest); if (httpResponse.getStatusLine().getStatusCode() == 200) { //TODO } else... 阅读全文
posted @ 2012-07-16 14:25 悬崖上的蒲公英 阅读(142) 评论(0) 推荐(0) 编辑
摘要: android中全局变量的使用方法:class MyApp extends Application { private String myState; public String getState(){ return myState; } public void setState(String s){ myState = s; } }class Blah extends Activity { @Override public void onCreate(Bundle b){ … MyApp appState = ((MyApp)getApplicationContext()); String 阅读全文
posted @ 2012-07-16 14:25 悬崖上的蒲公英 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 创建自定义view的时候,碰到 android.view.InflateException: Binary XML file line #异常,反复研究后发现是缺少一个构造器造成。public MyView(Context context,AttributeSet paramAttributeSet) { super(context,paramAttributeSet);}补齐这个构造器,异常就消失了,如果碰到这个问题不妨试试看。 阅读全文
posted @ 2012-07-16 14:23 悬崖上的蒲公英 阅读(1507) 评论(0) 推荐(0) 编辑
摘要: Android有用的代码片段1:查看是否有存储卡插入String status=Environment.getExternalStorageState(); if(status.equals(Enviroment.MEDIA_MOUNTED)) { 说明有SD卡插入 }2:让某个Activity透明OnCreate中不设Layout this.setTheme(R.style.Theme_Transparent); 以下是Theme_Transparent的定义(注意transparent_bg是一副透明的图片)3:在屏幕元素中设置句柄使用Activity.findViewById来取得屏幕. 阅读全文
posted @ 2012-07-16 14:22 悬崖上的蒲公英 阅读(104) 评论(0) 推荐(0) 编辑
摘要: android布局属性详解 各种Layout用到的一些重要的属性: 第一类:属性值为true或false android:layout_centerHrizontal 水平居中 android:layout_centerVertical 垂直居中 android:layout_centerInparent 相对于父元素完全居中 android:layout_alignParentBottom 贴紧父元素的下边缘 android:layout_alignParentLeft 贴紧父元素的左边缘 android:layout_alignParentRight 贴紧父元素的右边缘 ... 阅读全文
posted @ 2012-07-16 14:20 悬崖上的蒲公英 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 1. 指定action 和type // SIM import Intent importIntent = new Intent(Intent.ACTION_VIEW); importIntent.setType(“vnd.android.cursor.item/sim-contact”); importIntent.setClassName(“com.android.phone”, “com.android.phone.SimContacts”); menu.add(0, 0, 0, R.string.importFromSim) .setIcon(R.drawable.ic_menu... 阅读全文
posted @ 2012-07-16 14:19 悬崖上的蒲公英 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 代码如下:Intent startMain = new Intent(Intent.ACTION_MAIN);startMain.addCategory(Intent.CATEGORY_HOME);startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);startActivity(startMain);System.exit(0);执行后在任务管理器看不到。 阅读全文
posted @ 2012-07-16 14:18 悬崖上的蒲公英 阅读(180) 评论(0) 推荐(0) 编辑
摘要: android在处理一写图片资源的时候,会进行一些类型的转换:1、Drawable → Bitmap 的简单方法 ((BitmapDrawable)res.getDrawable(R.drawable.youricon)).getBitmap();2、Drawable → Bitmap Java代码 public static Bitmap drawableToBitmap(Drawable drawable) { Bitmap bitmap = Bitmap .createBitmap( drawable.getIntrinsicWidth(), drawable.getIntrinsic. 阅读全文
posted @ 2012-07-16 14:15 悬崖上的蒲公英 阅读(134) 评论(0) 推荐(0) 编辑
摘要: android发送http get请求的方法String uriAPI = “http://www.getideas.cn“; /* 建立HTTP Get对象 */ HttpGet httpRequest = new HttpGet(uriAPI); try { /* 发送请求并等待响应 */ HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequest); /* 若状态码为200 ok */ if (httpResponse.getStatusLine().getStatusCode() == 20... 阅读全文
posted @ 2012-07-16 14:11 悬崖上的蒲公英 阅读(272) 评论(0) 推荐(0) 编辑
摘要: eclipse中Error generating final archive: Debug certificate expired on异常的解决方法Eclipse Android工程时,提示该错误 :Error generating final archive: Debug certificate expired on xxxxxx 解决办法:linux:Window--》Preferences--》Android--》Build中Default debug keystore显示了地址“/home/jinli/.android/debug.keystore”,删除此路径下的debug.key 阅读全文
posted @ 2012-07-16 14:10 悬崖上的蒲公英 阅读(93) 评论(0) 推荐(0) 编辑