Android项目开发实战常用知识点
来源:互联网 发布:c语言逻辑或怎么打手机 编辑:程序博客网 时间:2024/06/10 09:07
Android项目开发实战常用知识点
一:启动页延时两秒再跳转到主界面://执行类private class SlpashRunnable implements Runnable { @Override public void run() { Log.e("tag: ", "-----------------------"); //判断是不是首次登录 if (preferences.getBoolean("firstStart", true)) { SwitchAdTask switchAdTask = new SwitchAdTask( SlpashActivity.this); switchAdTask.execute(); } else { jumpHome(); } } }//再onCreate方法中调用以下代码:new Handler().postDelayed(new SlpashRunnable(), 2000);//延时两秒执行SlpashRunnable类二:用SharedPreferences判断应用是否第一次登陆:public class MainActivity extends Activity { private SharedPreferences spf; private Boolean b; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); spf = getSharedPreferences(Common.PACKANG_NAME, MODE_PRIVATE); b = spf.getBoolean("firstStart", true); if(b){ //第一次登陆 Log.e("tag: ", "first"); spf.edit().putBoolean("firstStart", false).commit(); }else{ //二次以上登陆 Log.e("tag: ", "second+"); } } }三:TextView选中变色1:在color文件夹里新建selector文件,这里取名text_tab_background.xml2:设置selector资源文件:<?xml version="1.0" encoding="utf-8" ?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:color="#C32F30" /><!-- 选择时的颜色 --> <item android:state_focused="true" android:color="#00FFFF" /><!-- 获得焦点是颜色 --> <item android:state_pressed="true" android:color="#FFff00" /><!-- 点击是的颜色 --> <item android:color="#a0a0a2"/><!-- 默认时的颜色 --></selector>3:定义组件<TextView android:id="@+id/tv_tab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="marquee" android:layout_marginBottom="3dp" android:singleLine="true" android:textColor="@color/text_tab_background"//在此次设置 android:textSize="13sp" />四:Button设置变色:1:在drawable文件夹里新建selector文件,这里取名item_select.xml2:分别制造两张同等类型不同颜色的九妹.9.png背景图3:设置selector资源文件:<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/z_2" //背景图的android:state_pressed="true"/> <item android:drawable="@drawable/z_1" android:state_focused="false" android:state_pressed="false"/> <item android:drawable="@drawable/z_2" android:state_focused="true"/> <item android:drawable="@drawable/z_1" android:state_focused="false"/></selector>4:定义组件: <Button android:id="@+id/but" android:layout_width="80dp" android:layout_height="40dp" android:text="点击变色" android:background="@drawable/item_select"/> 五:未ImageView设置旋转动画(循环旋转): 1:在res/anim文件夹下新建rotate旋转动画文件,share_anim.xml <?xml version="1.0" encoding="utf-8"?><rotate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="1000" android:fromDegrees="0" android:interpolator="@android:anim/linear_interpolator" android:pivotX="50%" android:pivotY="50%" android:repeatCount="infinite" android:toDegrees="+360" /> 2:设置布局: <ImageView android:id="@+id/shareImage" android:pivotX="50%" android:pivotY="50%" android:layout_width="47dp" android:layout_height="47dp" android:layout_gravity="center_vertical" android:src="@drawable/sy_tb_4" />3:在Activity文件中绑定动画:setRotate(this,shareImage);//为分享图片设置动画 /** * 旋转动画 * @param mcontext */ public void setRotate(Context mcontext,ImageView image){ Animation anim = AnimationUtils.loadAnimation(mcontext, R.anim.share_anim); LinearInterpolator lir = new LinearInterpolator(); anim.setInterpolator(lir); image.startAnimation(anim); }六:字符串:6.1字符串格式化:String toast = String.format("%s%d", "您的当前总积分为:", allScore);//%s代表字符串;%d代表整形,意思是将前半部分转换为String,allScore转换为整形七:设置控件的隐藏,显示,不可见和不可点击等状态android:visibility="visible" //控件正常显示android:visibility="invisible" //不可见android:visibility="gone"//隐藏android:enabled="false"//不响应操作,颜色为灰色android:editable="false"//编辑款不可编辑android:ems="10"//设置控件长点为10个单位,超出部分不再显示android:ellipsize="none"//设置为单行显示
0 0
- Android项目开发实战常用知识点
- Android开发----实战项目
- android开发常用知识点备忘录
- Android项目开发实战:倒计时
- Android项目开发实战:倒计时
- Android 项目中常用小知识点.
- Android实战开发租赁管理软件视频教程 Android项目实战教程
- 【网络爬虫项目】实战知识点
- Android经典项目案例开发实战宝典
- Android应用开发项目实战视频教程
- J2EE实战开发Android项目视频教程
- Android 项目开发实战:图案解锁
- Android项目开发实战:2D翻转
- Android 项目开发实战:答题系统
- Android项目开发实战-2048游戏
- 开发常用小知识点
- JAVA开发常用知识点
- iOS 开发一周速成 -- 项目实战中常用API
- NPOI2.2.0.0实例详解(三)—设置EXCEL列宽、行高与合并单元格
- Eclipse设置
- js处理new Date()获取的时间
- 在Windows上部署NTP Server
- Mybatis的ResultMap的使用
- Android项目开发实战常用知识点
- SxsTrace工具使用方法
- nginx与tomcat、memcached 集群Session共享
- datagrid的列非常多的时候,而且没有表格数据,横向滚动条不会显示
- 不同关卡的通讯
- maven项目无法运行在Tomcat环境
- 关于onSaveInstaceState的一点小误解
- Objc-C 知识点回顾 四 NSString 、NSMutableString
- piwik源码安装