**2.**多张图片异步上传
首先来看一下布局文件:
<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:background=“#f2f2f2” >
<LinearLayout
android:id=“@+id/layout_CONTENT”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:background=“#f2f2f2”
android:orientation=“vertical”
android:padding=“5dp” >
<LinearLayout
android:id=“@+id/layout_container”
android:layout_width=“300dp”
android:layout_height=“wrap_content”
android:layout_gravity=“center_horizontal”
android:layout_margin=“5dp”
android:background=“#cbcbcb”
android:orientation=“vertical”
android:padding=“0.2px” />
<TextView
android:id=“@+id/text_no_data”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_margin=“20dp”
android:text=“@string/text_picture_upload”
android:textSize=“16dp” />
布局很简单,主要是id为layout_container的一个LinearLayout作为父布局。
横向的线条和纵向的线条布局也很简单:
<View xmlns:android=“http://schemas.android.com/apk/res/android”
android:layout_width=“match_parent”
android:layout_height=“1px”
android:background=“#cbcbcb” />
<View xmlns:android=“http://schemas.android.com/apk/res/android”
android:layout_width=“1px”
android:layout_height=“match_parent”
android:background=“#cbcbcb” />
下面是动态生成布局的实现方式:
private void initUI() {
setContentView(R.layout.activity_main);
//setTitle(R.string.button_service_upload_picture);
//showBackwardView(R.string.button_backward, true);
//showForwardView(R.string.button_upload,true);
//最顶层父布局
mLayout = (ViewGroup) findViewById(R.id.layout_container);
final int count = 9; //9格
final int rowCount = (count + 2) / 3;
for (int i = 0; i < rowCount; i++) {
if (i != 0) {
//加载横向布局线条
View.inflate(this, R.layout.layout_line_horizonal, mLayout);
}
//创建布局对象,设置按下颜色
final LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setBackgroundResource(R.drawable.row_selector);
for (int j = 0; j < 3; j++) {
if (j != 0) {
//加载内层纵向布局线条
View.inflate(this, R.layout.layout_line_vertical, linearLayout);
}
ImageButton imageButton = new ImageButton(this);
imageButton.setBackgroundResource(R.drawable.row_selector);
imageButton.setTag(TAG);
imageButton.setOnClickListener(this);
imageButton.setEnabled(false);
LinearLayout.LayoutParams layoutParams =
new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f);
//添加到linearLayout布局中
linearLayout.addView(imageButton, layoutParams);
//将imageButton对象添加到列表
mImageButtonList.add(imageButton);
}
DisplayManager manager = DisplayManager.getInstance();
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, manager.dipToPixel(100));
//将View添加到总父布局
mLayout.addView(linearLayout, layoutParams);
}
//外层设置ImageButton属性
final ImageButton currentImageButton = mImageButtonList.get(mCurrent);
currentImageButton.setImageResource(R.drawable.ic_add_picture);
currentImageButton.setScaleType(ScaleType.CENTER);
currentImageButton.setEnabled(true);
}
图片上传功能:
private class UploadPictureTask extends AsyncTask<List, Integer, String> {
/* (non-Javadoc)
- @see android.os.AsyncTask#doInBackground(Params[])
*/
@Override
protected String doInBackground(List… params) {
final List pictureList = params[0];
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)
总结
可以看出,笔者的工作学习模式便是由以下 「六个要点」 组成:
❝ 多层次的工作/学习计划 + 番茄工作法 + 定额工作法 + 批处理 + 多任务并行 + 图层工作法❞
希望大家能将这些要点融入自己的工作学习当中,我相信一定会工作与学习地更富有成效。
下面是我学习用到的一些书籍学习导图,以及系统的学习资料。每一个知识点,都有对应的导图,学习的资料,视频,面试题目。
**如:我需要学习 **Flutter的知识。(大家可以参考我的学习方法)
- Flutter 的思维导图(无论学习什么,有学习路线都会事半功倍)
- Flutter进阶学习全套手册
- Flutter进阶学习全套视频
大概就上面这几个步骤,这样学习不仅高效,而且能系统的学习新的知识。
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
**
[外链图片转存中…(img-rfWrReKj-1713277464145)]
- Flutter进阶学习全套手册
[外链图片转存中…(img-ejHvU6jP-1713277464147)]
- Flutter进阶学习全套视频
[外链图片转存中…(img-MLAg3Jal-1713277464148)]
大概就上面这几个步骤,这样学习不仅高效,而且能系统的学习新的知识。
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!