
Android studio
写bug给别人改
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Fragment 动态切换碎片
// FragmentManager fragmentManager = getSupportFragmentManager();// FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();// fragmentTransaction.replace(R.id.right_layout,fragment);// fragmentTransaction.commi.原创 2021-01-10 20:03:58 · 172 阅读 · 0 评论 -
Fragment 碎片的使用
//需要有碎片类 //此处举例有左右两个碎片 //android:name="com.example.tabletproject.LeftFragment" //fragment 在布局中需要引入对应的类名(包名也要)//左碎片类public class LeftFragment extends Fragment { @Nullable @Override public View onCreateView(@NonNull LayoutInflater infla.原创 2021-01-10 19:46:03 · 119 阅读 · 0 评论 -
ImageView 中设置selector 不显示解决方法
原因:按压状态代码需要放在普通状态代码上方不显示代码<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <!--初始状态--> <item android:drawable="@mipmap/nav_me_normal"/> <!--按压状态--.转载 2020-12-13 22:01:07 · 344 阅读 · 0 评论 -
android studio 闪屏页实现
//可以让页面延迟两秒后启动第二个活动 //Handler类的方法 postDelayed(Runnable,long); Runnable:线程 long:页面停留时间ms myHandler.postDelayed(new Runnable() { @Override public void run() { //延迟时间2秒后运行此线程语句 从此活动跳转TwoActivity ...原创 2020-12-10 00:09:15 · 1096 阅读 · 0 评论 -
android studio 报错No layout manager attached; skipping layout
说明没有使用layout manager完整使用 LinearLayoutManager layoutManager = new LinearLayoutManager(this); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); recyclerView.setLayoutManager(layoutManager); //使用管理器原创 2020-11-29 09:06:51 · 532 阅读 · 0 评论 -
android studio 使用.9.png出现AGPBI: {“kind“:“error“,“text“:“Android resource compilation failed“,“source
第一种: .9.png图只能(必须)画四条线,在画的过程中如果多画了线就会报此错误(如下图) 上、左线: 拉伸区 下、右线: 内容显示区 正确形式:第二种:文件名可能不符合标准 引用某网友所言 ...原创 2020-11-28 17:54:28 · 1128 阅读 · 0 评论 -
android studio findViewById得到null
参考文章:https://www.cnblogs.com/therock/articles/3695016.html 网上找到的原因是:想要获得的控件不是本活动的layout 比如我创建的活动PersonActivity 一并生成的person_layout被我删掉 然后重新创建了一个 此时新layout与PersonActivity无关系 解决方法:先获得view 再用view调用findViewById View view = LayoutInflater.from原创 2020-11-28 11:06:20 · 415 阅读 · 0 评论 -
android studio RecycleView
首先在build.gradle文件下dependencies下添加如下代码首先在build.gradle 文件下dependencies下添加如下代码(添加依赖项) def recyclerview_version = "1.0.0" implementation "androidx.recyclerview:recyclerview:$recyclerview_version" implementation "androidx.recyclerview:recyclerview.原创 2020-11-24 22:59:18 · 183 阅读 · 0 评论 -
android studio 隐藏标题栏
在活动中添加下列语句//第一种// ActionBar actionBar = getSupportActionBar().hide();// if(actionBar !=null){//// actionBar.hide();//// }//第二种 getSupportActionBar().hide();原创 2020-11-21 19:45:42 · 151 阅读 · 0 评论 -
android studio ListView使用
class参考书籍《第一行代码》Fruit适配器public class FruitAdapter extends ArrayAdapter { private int resourceId; public FruitAdapter(@NonNull Context context, int textViewResourceId, List<Fruit> objects) { super(context,textViewResourceId,obje原创 2020-11-19 11:36:37 · 300 阅读 · 0 评论 -
android studio 自定义标题栏
加粗样式 代码解释 /* 需要动态加载标题栏,要用到LayoutInflater对象,LayoutInflater的from方法可以生成 LayoutInflater对象 然后用inflate方法调用布局,第一个参数是布局文件id, 第二个是已经加载好的布局的父布局,这里用TitleLayout */ LayoutInflater.from(context).inflate(R.layout.title_layout,this);TitleLayo原创 2020-11-15 11:40:55 · 1004 阅读 · 0 评论 -
android studio百分比布局
PercentRelativeLayout 在build.gradle添加依赖库: implementation 'androidx.percentlayout:percentlayout:1.0.0' 代码解释: xmlns:app="http://schemas.android.com/apk/res-auto" 添加一个app命名空间 <?xml version="1.0" encoding="utf-8"?><androidx.percentlayout.wid原创 2020-11-14 17:54:52 · 912 阅读 · 0 评论 -
android studio 线性布局
LinearLayout 参考文章《第一行代码》 android:layout_weight="1" //占该行的权重(Button未设置)100% android:orientation="horizontal" //线性布局方向 horizontal vertical android:layout_width="match_parent" //宽度: match_parent(屏幕大小) wrap_content(组件够用) /* 当Li原创 2020-11-14 16:37:33 · 523 阅读 · 0 评论 -
android studio 部分控件代码
常用控件代码参考文章《第一行代码》/* gravity 作用:指定文本的对齐方式 gravity 参数:top buttom left right center 可多个结合: top|left center_vertical|horizontal_center 相当于 center maxLines 设定最大行数 在EditText(文本输入框)中使用当用户输入数据超过行时向上滚动 不会继续拉长*/ <EditText原创 2020-11-14 15:51:17 · 239 阅读 · 0 评论 -
android studio AlertDialog(提示框)
AlertDialog setTitle("AlertDialog"); 设置提示框的窗口标题 setMessage("确定删除?"); 设置提示信息 setPositiveButton("确定",new DialogInterOnClickListener(){}); setNegativeButton("取消",new DialogInterOnClickListener(){}) case R.id.button: AlertDialog.Builder dialo原创 2020-11-14 15:40:29 · 535 阅读 · 0 评论 -
android studio 设置ProcessBar(进度条)
ProcessBar (进度条)参考文章《第一行代码》参考文章: https://blog.youkuaiyun.com/hou09tian/article/details/80445141 /* 设置可见性: visible可见 View.VISIBLE invisible不可见但仍占用控件(类似透明但还在原位置) View.INVISIBLE gone不可见且不占用屏幕空间 View.GONE android:v原创 2020-11-14 11:41:23 · 1267 阅读 · 0 评论 -
android studio 一键退出所有活动
1.创建一个新类:ActivityCollector用于管理活动 活动继承 --- 在新类中用List存储新的活动 addActivity(Activity activity):添加新活动 removeActivity(Activity activity):退出指定活动 finishAll() :退出所有活动public class ActivityCollector { public static List<Activity> act原创 2020-11-13 20:52:45 · 793 阅读 · 0 评论 -
android studio 写相册
MainActivity函数package com.example.xml_and_java_layout;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;import android.view.ViewGroup;import android.widget.GridLayout;import android.widget.ImageView;public class MainActivit原创 2020-10-25 22:07:11 · 1275 阅读 · 0 评论 -
android studio 绘制计算器UI
代码解释android:background="@drawable/shape_rectangle" 引用自己写的背景android:textSize="30sp" 字体大小android:gravity="center" 字体居正中android:gravity="center_vertical" 字体居竖直方向的中android:paddingLeft="50dp"原创 2020-10-14 21:21:01 · 210 阅读 · 0 评论 -
android studio 帧布局
FrameLayout 帧布局android:background="@color/colorAccent" 背景颜色android:layout_gravity="center"/> 放置中间 <?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/原创 2020-10-10 22:36:06 · 634 阅读 · 0 评论 -
android studio 表格布局
TableLayout 表格布局应用于: 输入法 计算器等UI 演示代码<?xml version="1.0" encoding="utf-8"?><TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" andro原创 2020-10-10 22:25:36 · 1893 阅读 · 0 评论 -
android studio 绝对布局
AbsoluteLayout 绝对布局绝对布局依靠坐标确定位置<?xml version="1.0" encoding="utf-8"?><AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <!-原创 2020-10-10 22:10:06 · 1385 阅读 · 0 评论 -
android studio 相对布局
RelativeLayout :相对布局1.基于父控件的布局基于父控件可将父控件理解成整个框架 控件默认在左边android:layout_centerInParent="true" 基于父控件中间(正中间)android:layout_alignParentRight="true" 基于父控件右边(右方)android:layout_alignParentBottom="true" 基于父控件下方(下方)演示代码<?xml version="1.0" enc原创 2020-10-10 21:54:12 · 368 阅读 · 0 评论 -
gradle-5.4.1-all.zip下载与替换
** gradle-5.4.1-all.zip文件群自取344386405 (非本人创建侵权删)**今天下载android studio 使用时出现出现错误:ERROR: Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-5.4.1-all.zip'.解决方法 1.将以下文件夹下的数据删掉 我的C:\Users\Hasee\.gradle\wrap原创 2020-10-07 22:48:08 · 13049 阅读 · 0 评论