Android项目大全(总有你用的到的)

来源:互联网 发布:淘宝买家怎么删除追评 编辑:程序博客网 时间:2024/06/05 03:35

1.史上最快Android模拟器:Genymotion使用教程 :

genymotion模拟器安装输入法失败(提示不兼容)下载这个文件拖到模拟器中,安装成功后重启  

2.INSTALL_FAILED_CPU_ABI_INCOMPATIBLE解决办法  

3.Android Smart Image View的使用 

4.Android开发:在EditText中关闭软键盘
// 点击空白处 软键盘消失@Overridepublic boolean onTouchEvent(MotionEvent event) {InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);return imm.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);}

// 检查软件盘是否依然显示着的,如果是则关闭。if (imm.isActive()) {imm.hideSoftInputFromInputMethod(v.getApplicationWindowToken(),0);}



5.Android--点击EditText的时候弹出软键盘,点击EditText之外空白处软键盘消失,android--edittext


6.(1)判断桌面快捷方式是否存在
/** * 判断桌面快捷方式是否存在 */private boolean hasShortcut() {boolean isInstallShortcut = false;final ContentResolver cr = this.getContentResolver();String AUTHORITY = null;if (android.os.Build.VERSION.SDK_INT < 8)AUTHORITY = "com.android.launcher.settings";elseAUTHORITY = "com.android.launcher2.settings";final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY+ "/favorites?notify=true");Cursor c = cr.query(CONTENT_URI,new String[] { "title", "iconResource" },"title=?",new String[] { this.getString(R.string.app_name).trim() },null);if (c != null && c.getCount() > 0) {isInstallShortcut = true;c.close();}return isInstallShortcut;}
6.(2)为程序创建桌面快捷方式
private void addShortcut() {Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");// 快捷方式的名称shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,getString(R.string.app_name));shortcut.putExtra("duplicate", false); // 不允许重复创建Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);shortcutIntent.setClassName(this, this.getClass().getName());shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);// 快捷方式的图标ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher);shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);sendBroadcast(shortcut);}

7动态切换两个EditText中的数据,并且两个EditText都不能为空
if (TextUtils.isEmpty(edittext1.getText())) {Toast.makeText(context, "edittext1为空", Toast.LENGTH_SHORT).show();} else if (TextUtils.isEmpty(startPlaceEdit.getText())) {Toast.makeText(context, "<span style="font-family: Arial, Helvetica, sans-serif;">edittext2</span>为空", Toast.LENGTH_SHORT).show();}// 交换出发地和目的地CharSequence[] charSequences = new CharSequence[] {edittext2.getText(), edittext1.getText() };edittext1.setText("");edittext2.setText("");<pre name="code" class="java"><span style="white-space:pre"></span>edittext1<span style="font-family: Arial, Helvetica, sans-serif;">.setText(charSequences[0]);</span>
wdittext2.setText(charSequences[1]);

8.Android中Textview显示带html

9.Actionbar修改背景色:
在style.xml中重写一下:
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">          <!-- API 14 theme customizations can go here. -->          <item name="android:actionBarStyle">@style/my_actionbar_style</item>       </style>            <style name="my_actionbar_style" parent="@android:style/Widget.Holo.Light.ActionBar">          <item name="android:background">#647b97</item>      </style>  

10. 获取android手机基本信息

 /**      * 获取IMEI号,IESI号,手机型号      */  public static void getPhoneInfo(Context context) {            TelephonyManager mTm = (TelephonyManager)context.getSystemService(context.TELEPHONY_SERVICE);             String imei = mTm.getDeviceId();             String imsi = mTm.getSubscriberId();             String mtype = android.os.Build.MODEL; // 手机型号             String mtyb= android.os.Build.BRAND;//手机品牌             String numer = mTm.getLine1Number(); // 手机号码,有的可得,有的不可得             Log.i("手机信息", "手机IMEI号:"+imei+"手机IESI号:"+imsi+"手机型号:"+mtype+"手机品牌:"+mtyb+"手机号码"+numer);         }


11. AndroidStudio高级配置

12.android官方侧滑菜单DrawerLayout详解 http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/0925/1713.html#goodfb5567     2016-8-30 11:10:21
13.Glide框架及源码解析 https://xiaodanchen.github.io/archives/  2016-8-30 11:13:25
14.多窗口支持 https://developer.android.com/guide/topics/ui/multi-window.html(需科学上网)2016-9-2 09:20:08
3 0