0 学习材料
1 开发环境配置
Windows下搭建Eclipse+Android4.0开发环境
2. 程序调试相关
2.1 LogCat没有任何输出的解决方法。
(1) 使用模拟器没有输出。网上相关的小讨论
对我有效的方法:进入DDMS界面,点击一下Devices栏中的现有设备即可。
(2) 使用真机调试没有输出。解决方法:华为u8500在usb模式下logcat无法打印信息
2.2 . andoid上调试出现如下问题,导致无法安装:
[2012-01-09 13:12:59 - ppclassclient0] Re-installation failed due to different application signatures. [2012-01-09 13:12:59 - ppclassclient0] You must perform a full uninstall of the application. WARNING: This will remove the application data! [2012-01-09 13:12:59 - ppclassclient0] Please execute 'adb uninstall com.jwtech.ppclassclient' in a shell. [2012-01-09 13:12:59 - ppclassclient0] Launch canceled!
解决方法:在机器上将需要调试但已经安装的程序卸载。
3. UI相关
3.1 Activity生命周期
3.3. android界面更新
3.3.1 通过handler更新界面
(1) 主线程中初始化handler
myHandler = new Handler() { public void handleMessage(Message msg) { switch (msg.what) { case GRASS: panel.invalidate(); break; } super.handleMessage(msg); } };
(2)其他线程中触发handler
Message message = new Message(); message.what = GRASS; myHandler.sendMessage(message);
3.5 FragmentActivity
3.6 app图标
3.6.1 andriod安装后显示/不显示图标
通过AndriodManifest.xml中的配置文件控制, eg.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.nmgfrank.nmgfrank" > <uses-permission android:name="android.permission.INTERNET"/> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:exported="true" android:name=".IndexActivity" android:label="@string/title_activity_index" > <intent-filter> <!-- 如果将下边两句配置注释掉, 则安装后,没有app图标 --> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
3.6.2 设置app图标图片. 注意:部分手机需要删除app并重启手机后,再加载新程序, 新图标方可显示。
3.7 按钮点击事件
protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.content_main); Button button = (Button) findViewById(R.id.button_id); // 将时间与按钮点击绑定 button.setOnClickListener(myOnClickListener); } //手动增加代码开始 private OnClickListener myOnClickListener = new OnClickListener() { public void onClick(View v) { // 点击后执行 } }; 3.8 App应用之启动画面
3.9 WebView的使用
3.9.1 软键盘遮挡input输入框。
修改AndriodManifest.xml
(1) 设置为非全屏android:theme=”@android:style/Theme.NoTitleBar”
(2) 相应的activity, 设置android:windowSoftInputMode=”stateHidden|adjustResize”
4. andriod数据相关
4.1 android操作系统中读写文件
写数据
//实例化SharedPreferences对象 SharedPreferences mySharedPreferences= getSharedPreferences("test", Activity.MODE_PRIVATE); //实例化SharedPreferences.Editor对象 SharedPreferences.Editor editor = mySharedPreferences.edit(); //用putString的方法保存数据 key, value editor.putString("name", "Karl"); //提交当前数据 editor.commit();
读数据
// 实例化SharedPreferences对象 SharedPreferencessharedPreferences= getSharedPreferences("test", Activity.MODE_PRIVATE); // 使用getString方法获得value,注意第2个参数是value的默认值 String name =sharedPreferences.getString("name", "");
4.4 zxing二维码生成与识别, 需要配合作者所附的demo一并理解
4.5 Sqlite
SQlite之可视化插件: SQLScout的安装(没有激活码的话, 可以安装试用版, 试用三天),
4.7 判断网络是否为WIFI
4.8 数据推送
5 系统参数
5.1 获取android手机的CPU,内存,磁盘等基本信息
5.2 手机与电脑相连后,命令提示符中输入:adb shell netcfg 似乎就可以看到ip。
6 h5
7、Andriod Studio
Andriod Studio使用教程
Andriod Studio使用教程2