Android手机返回键重写
摘要:public void onBackPressed() { //点击返回键所执行代码}
阅读全文
Android用代码实现home键的功能
摘要:Intent intent = new Intent();intent.setAction(Intent.ACTION_MAIN);intent.addCategory(Intent.CATEGORY_HOME); startActivity(intent);
阅读全文
Android跳转到手机系统设置页面方法
摘要:使用实例例: startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)),即可跳到android手机网络设置页面。如果要launch Mobile Networks Setting页面按如下方法: Intent intent=new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS); ComponentName cName = new ComponentName(“com.android.phone”,”com.android.phone.Settings”); intent....
阅读全文
Android中把GPS坐标转换为百度地图坐标
摘要:p = new GeoPoint(lat, lon);p1 = CoordinateConvert.fromWgs84ToBaidu(p);p为GPS坐标点,p1为百度坐标点
阅读全文
java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.MyApplication
摘要:<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:name="com.athena.www.common.MyApplication" > 出现这个的错误原因就是在manifest.xml文件中没有加android:name="com.athena.www.common.MyApplication"
阅读全文
Android用代码实现GPS的开启/关闭功能+网络开关
摘要:在网上看到很多关于Settings源代码,都需要添加什么权限,而有些权限有是系统权限,不让设置,下面的方法不需要任何权限就能实现当前GPS状态为开启状态,代码运行后则关闭;反之,则开启Intent GPSIntent = new Intent();GPSIntent.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");GPSIntent.addCategory("android.intent.category.
阅读全文
Android中焦点的设置
摘要:在布局文件中添加,就OK了在布局文件中,在EditText前面放置一个看不到的LinearLayout,让他率先获取焦点: 二、android:cursorVisible="false" 移除光标三、android:windowSoftInputMode="stateHidden" 隐藏输入法
阅读全文
Android中获取手机的IMEI码
摘要:添加权限:<uses-permissionandroid:name="android.permission.READ_PHONE_STATE"/>获取IMEI:TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); final String imei = "DeviceId(IMEI) = " + tm.getDeviceId();
阅读全文
Android在监听器中使用代码改变其他控件背景或颜色
摘要:button.setBackgroundResource(R.color.button_click);button1.setBackgroundResource(R.color.button);
阅读全文
Android中@+id/android:list"和"@android:id/list"的区别
摘要:使用ListActivity,在Activity的Layout文件中必须包括一个(只能一个)ListView,且ListView的id="@id/android:list",在 Activity 中使用 setListAdapter(adapter); 时就默认设置到了这个list上。 如果按一般控件的写法 <ListView android:id="@+id/myListView" …… />,则需要 findViewById先得到控件对像,再调用对像的 setListAdapter(adapter);
阅读全文
Android中item间的分割线问题
摘要:使用divider属性:添加背景:android:divider="@drawable/list_driver"。改变颜色:android:divider="#000000"。去 掉:android:divider="@null"。
阅读全文
Android中在点击ListView的item时改变其背景
摘要:设置背景:drawable/inform_item_background.xml<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android" >//没有焦点时的图片背景 <item android:state_window_focused="false" android:drawable="@drawable/inform_i
阅读全文
Android在布局文件中加一条分割直线
摘要:<View android:layout_width="fill_parent" android:layout_height="1px" android:background="?android:attr/listDivider" />
阅读全文