![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Android
藏鹿
这个作者很懒,什么都没留下…
展开
-
listview的item高度无法设置
原先用得是view = View.inflate(MainActivity.this,R.layout.item_view,null);root不可以为空所以换成以下方法view = LayoutInflater.from(MainActivity.this).inflate(R.layout.item_view,parent,false);原创 2020-05-25 20:56:04 · 216 阅读 · 0 评论 -
Activitu启动与退出动画
Android提供了是页面切换界面更加优雅的方法 /** * @param enterAnim A resource ID of the animation resource to use for * the incoming activity. Use 0 for no animation. * @param exitAnim A resource ID o...原创 2020-05-25 15:34:17 · 250 阅读 · 0 评论 -
TextView的跑马灯效果
TextView的基本属性和设置方法跑马灯用到的属性与方法省略方式的取值实现原创 2020-05-19 12:04:55 · 114 阅读 · 0 评论 -
android数据存储
一、sharedPreferences1、获取的两种方式调用Context对象的getSharedPreferece(文件名,操作模式)调用Activity对象的getSharedPreferece方法 //存储一个用户名 SharedPreferences sp = getApplicationContext().getSharedPreferences("filename",MODE_PRIVATE); SharedPreferences.Editor edito原创 2020-05-18 22:26:31 · 79 阅读 · 0 评论 -
RealtiveLayout相对布局的属性
第一类:属性值为true或false第二类:属性值必须为id的引用名第三类:属性为具体的值原创 2020-05-18 22:03:34 · 143 阅读 · 0 评论 -
android支持的像素单位
1、px:像素,手机屏幕上可显示的最小单位。2、in:英寸3、mm:毫米4、pt:磅。1/72英寸5、dp:与设备无关的显示单位,只与显示屏有关。6、dip,即dp7、sp,用于设置字体大小dp与px的转换android用于设置大小的函数都以px为单位。要想在代码中使用dp设置布局大小或间距,都得先把dp转为px值// 将10dp的尺寸大小转换为对应的px数值 int dip_10 = Utils.dip2px(this, 10L); // 从布局文件中获取名叫tv_原创 2020-05-18 21:45:07 · 1042 阅读 · 0 评论 -
WelcomeActivity延迟跳转至MainActivity
//创建一个定时器 mTimer = new Timer(); mTimer.schedule(new TimerTask() { @Override public void run() { startActivity(new Intent(WelcomeActivity.this,MainActivity.class)); } },3*1000);//延.原创 2020-05-13 18:54:10 · 223 阅读 · 0 评论 -
SImpleAdapter的使用
布局文件settings_item<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:gravity="center_vertical" android:orientation=原创 2020-05-10 22:32:10 · 115 阅读 · 0 评论 -
ArrayAdapter的使用
String[] objects = new String[]{"换肤","分享","关于"}; mListView.setAdapter(new ArrayAdapter<String>(this,R.layout.settings_item,objects));在settings_item布局文件中,原先是用一个LinearLayout包裹一个TexiView,这样是不成功的。...原创 2020-05-10 22:04:13 · 539 阅读 · 0 评论 -
利用隐式意图打开系统浏览器
首先拿到浏览器源码的意图过滤器,如下<intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <da原创 2020-05-10 17:50:01 · 1358 阅读 · 0 评论 -
子线程更新UI的四种方法
一、用Activity对象的runOnUiThread方法mTvContent = findViewById(R.id.tv_content); new Thread(){ @Override public void run() { runOnUiThread(new Runnable() { ...原创 2020-05-07 11:54:51 · 718 阅读 · 0 评论 -
Android——Intent传递信息
Intent组成元素一、显示意图需要指定被开启的类名或路径名,一般用于启动同一应用中的Aactivity声明方式//第一种:在构造函数中指定Intent intent = new Intent(this,Res.class);//第二种:调用setClass方法Intent intent = new Intent();intent.setClass(this,Res.class);...原创 2020-05-06 19:07:33 · 284 阅读 · 0 评论 -
Activity的生命周期
与生命周期有关方法onCreate:创建界面。把页面上的各个元素加载到内存onStart:开始界面。把页面显示到屏幕上。onResume:恢复页面。让页面上的屏幕活动起来。onPause:暂停页面。让页面在屏幕上的动作停下来。onStop:停止页面。把页面从屏幕上撤下来onDestroy:销毁页面。把页面从内存中清除。onRestart:重启页面。重新加载内存中的数据。以常见业务场...原创 2020-04-26 20:43:11 · 167 阅读 · 0 评论 -
Activity四种启动模式
可以在AndroidManifest.xml文件中给Activity设置android:launchMode=“standard”一、standard 标准模式Activity默认启动模式。这种模式每次启动一个Activity都会创建一个新的实例。二、singleTop 单一顶部模式如果新打开的Activity已经在栈顶了,就不会重新创建Activity,而是复用这个在栈顶的Activit...原创 2020-04-26 20:23:39 · 120 阅读 · 0 评论 -
Android横竖屏切换
无论是横屏切换到竖屏,还是从竖屏切换至横屏,都是原页面从onPause——>onStop——>onDestroy一路销毁新页面onCreate——>onStart——>onResume一路创建所以应该做好横竖屏切换后一些状态或数据的保存。第一种方法:横竖屏固定,此方法简单粗暴有效,但不能依赖android:screenOrientation="portrait...原创 2020-04-26 12:11:50 · 334 阅读 · 0 评论 -
Android自定义Button
一、在style文件中添加一个style<style name="btn"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">wrap_content</item> ...原创 2020-04-16 13:00:22 · 1157 阅读 · 0 评论 -
Android自定义Toast
官方封装的ToastToast.makeText(this, "提示", Toast.LENGTH_SHORT).show;自定义Toast一、思路:使用Toast对象的setView()方法二、实现1、首先准备一个Toast的布局文件toast_msg.xml<?xml version="1.0" encoding="utf-8"?><LinearLayout ...原创 2020-04-16 12:18:56 · 138 阅读 · 0 评论