Android学习笔记
来源:互联网 发布:无水印视频剪辑软件 编辑:程序博客网 时间:2024/05/21 09:21
Android小知识
一. Android系统启动后,直接进入到自己的程序
1.在想要启动程序中接收开机完成的广播android.intent.action.BOOT_COMPLETED,然后启动需要的activiy就可以
2.修改源程序,在自己的程序中加上<category android:name="android.intent.category.HOME" />
1的方法lanuch程序还在,而第二种却没有
二.android音乐播放器开发中
IntentFilter intentfilter=new IntentFilter();
intentFilter.addDataScheme("file");这代码如果不加的话,不能监听到Sd卡的插拔事件...
三.在listview的XML文件下加android:divider="@null",可以将每个item的下划线去掉
四.在Activity里在EditText输入时会弹出虚拟键盘,点击activity其他空白处隐藏虚拟键盘
public boolean onTouchEvent(MotionEvent event)
{
/** 获得系统服输:输入法 */
InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
int action = event.getAction();
switch (action)
{
case MotionEvent.ACTION_DOWN:
// 点击空白处软键盘消失
imm.hideSoftInputFromWindow(pwdEdt.getWindowToken(), 0);
imm.hideSoftInputFromWindow(usrEdt.getWindowToken(), 0);
break;
}
return false;
}
//pwdEdt,usrEdt为登陆界面的2个EditText.
五.定义自己的Toast(加图片http://blog.csdn.net/dyllove98/article/details/8811006)
public class ToastUtil
{
public static void show(Context context, String message)
{
Toast toast = new Toast(context);
View view = LayoutInflater.from(context).inflate(R.layout.toast, null);
TextView textView = (TextView)view.findViewById(R.id.toast_text);
textView.setText(message);
toast.setView(view);
toast.setDuration(Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 50);
toast.show();
}
}
对应的XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="#000000" >
<TextView android:id="@+id/toast_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:textStyle="normal"
android:paddingLeft="20dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingRight="20dp"
android:textColor="@android:color/background_light"
></TextView>
</LinearLayout>
六.得到本地客户端的版本信息
public void getCurrentVersion()
{
try
{
String packAge = context.getPackageName();
//得到当前的版本名
currentVersionName = context.getPackageManager().getPackageInfo(packAge, 0).versionName;
currentVersionCode = String.valueOf(context.getPackageManager().getPackageInfo(packAge, 0).versionCode);
}
catch (NameNotFoundException e)
{
//记录日志
}
}
七.mainfest的activity属性
<activity
android:configChanges="orientation|keyboardHidden" //表示activity横竖屏切换时,activity生命周期不重新来一遍而闪屏
android:name=".UI.BenchMarkUI"
android:screenOrientation="sensorPortait" > //表示不横竖屏切换
</activity>
八.Mars_ Android视频开发教程源码第1至5季http://bbs.csdn.net/topics/390307071
九.android项目乐淘 http://download.csdn.net/download/xuweilinjijis/5241901
十.脚本语言学习python http://czug.org/index.rst
11 Q群244763380
12 反编译APK http://blog.csdn.net/sunboy_2050/article/details/6727581
13 Android网络编程以及Android资料(安卓巴士,安卓实例和游戏源码) http://bbs.csdn.net/topics/390073205
14博客园资料 http://www.cnblogs.com/
15.tabHost刷新其中的Activity
16.ScrollView嵌套ExpandableListView时,扩展不显示,需要计算告诉:
private void setListViewHeight(ExpandableListView listView)
{
ListAdapter listAdapter = listView.getAdapter();
int totalHeight = 0;
int count = listAdapter.getCount();
for (int i = 0; i < listAdapter.getCount(); i++)
{
View listItem = listAdapter.getView(i, null, listView);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
listView.requestLayout();
}
- Android学习笔记--Gson笔记
- Android学习笔记
- Android学习笔记(二)
- android学习笔记--序
- android学习笔记1
- android学习笔记2
- android学习零碎笔记
- Android 学习笔记
- Android学习笔记(一)
- Android ExpandableListActivity 学习笔记
- Android EditText 学习笔记
- Android学习笔记3
- Android学习笔记4
- Android学习笔记5
- Android学习笔记9
- Android Animation学习笔记
- Android 学习笔记
- Android 数字签名学习笔记
- Android MediaPlayer 字幕同步【2】
- android 电话接听流程解析
- 第五周任务一 第四个
- 老板的三句话
- ‘FI_TEXT_ZTERM’ 读取Payment Terms描述
- Android学习笔记
- Oracle Rownum 伪列详解
- 游标、事务并发和锁三者之间的那点事
- ubuntu 终端显示汉字
- Eclipse快捷键
- Simple-Spring-memcached
- 久别重逢的 std::bad_alloc
- 深入浅出REST
- .net中事务的使用