Android UI-开源框架ImageLoader的完美例子,正在准备面试

从GitHub到海浪模拟:手把手教你配置WAVEWATCHⅢ 6.07.0的完整开发与测试环境 本文详细指导如何在Ubuntu系统中配置WAVEWATCHⅢ 6.07.0的开发与测试环境,涵盖虚拟机设置、依赖安装、源码编译及案例验证的全流程。通过步骤化教程,帮助科研人员快速搭建高效的海浪模拟平台,提升海洋数值模拟的研究效率。 阅读详情

从界面说起,界面本身是没什么好说的,就是如何在xml当中进行定义罢了

有以下这么多个布局文件

一个一个来看呗

首先是这样的效果

这个在Android4.2.2比较好看,在Android2.3.3就显得比较挫。

/2013.8.19_Universal_Image_Loader_Demo/res/layout/ac_home.xml

<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android=“http://schemas.android.com/apk/res/android”

android:layout_width=“fill_parent”

android:layout_height=“fill_parent” >

<LinearLayout

android:layout_width=“fill_parent”

android:layout_height=“fill_parent”

android:orientation=“vertical” >

<TextView

android:layout_width=“fill_parent”

android:layout_height=“wrap_content”

android:gravity=“center”

android:paddingBottom=“10dip”

android:paddingTop=“20dip”

android:text="@string/label_activity_examples"

android:textSize=“24sp” />

<Button

android:layout_width=“fill_parent”

android:layout_height=“wrap_content”

android:layout_margin=“10dip”

android:onClick=“onImageListClick”

android:text="@string/button_image_list" />

<Button

android:layout_width=“fill_parent”

android:layout_height=“wrap_content”

android:layout_margin=“10dip”

android:onClick=“onImageGridClick”

android:text="@string/button_image_grid" />

<Button

android:layout_width=“fill_parent”

android:layout_height=“wrap_content”

android:layout_margin=“10dip”

android:onClick=“onImagePagerClick”

android:text="@string/button_image_pager" />

<Button

android:layout_width=“fill_parent”

android:layout_height=“wrap_content”

android:layout_margin=“10dip”

android:onClick=“onImageGalleryClick”

android:text="@string/button_image_gallery" />

列表异步加载图片效果

/2013.8.19_Universal_Image_Loader_Demo/res/layout/ac_image_list.xml

<?xml version="1.0" encoding="utf-8"?>

<ListView xmlns:android=“http://schemas.android.com/apk/res/android”

android:id="@android:id/list"

android:layout_width=“fill_parent”

android:layout_height=“fill_parent” />

/2013.8.19_Universal_Image_Loader_Demo/res/layout/ item_list_image.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”

android:layout_width=“fill_parent”

android:layout_height=“wrap_content” >

<ImageView

android:id="@+id/image"

android:layout_width=“72dip”

android:layout_height=“72dip”

android:layout_margin=“3dip”

android:adjustViewBounds=“true”

android:contentDescription="@string/descr_image"

android:scaleType=“centerCrop” />

<TextView

android:id="@+id/text"

android:layout_width=“fill_parent”

android:layout_height=“wrap_content”

android:layout_gravity=“left|center_vertical”

android:layout_marginLeft=“20dip”

android:textSize=“22sp” />

GridView异步加载图片显示

/2013.8.19_Universal_Image_Loader_Demo/res/layout/ac_image_grid.xml

<?xml version="1.0" encoding="utf-8"?>

<GridView xmlns:android=“http://schemas.android.com/apk/res/android”

android:id="@+id/gridview"

android:layout_width=“fill_parent”

android:layout_height=“fill_parent”

android:gravity=“center”

android:horizontalSpacing=“4dip”

android:numColumns=“3”

android:stretchMode=“columnWidth”

android:verticalSpacing=“4dip”

android:padding=“4dip” />

/2013.8.19_Universal_Image_Loader_Demo/res/layout/item_grid_image.xml

<?xml version="1.0" encoding="utf-8"?>

<ImageView xmlns:android=“http://schemas.android.com/apk/res/android”

android:id="@+id/image"

android:layout_width=“fill_parent”

android:layout_height=“120dip”

android:adjustViewBounds=“true”

android:contentDescription="@string/descr_image"

android:scaleType=“centerCrop” />

ViewPager异步加载图片显示

**/2013.8.19_Universal_Image_Loader_Demo/res/layout/ac_image_pager.xml

**

<?xml version="1.0" encoding="utf-8"?>

<android.support.v4.view.ViewPager xmlns:android=“http://schemas.android.com/apk/res/android”

android:id="@+id/pager"

android:layout_width=“fill_parent”

android:layout_height=“fill_parent” />

/2013.8.19_Universal_Image_Loader_Demo/res/layout/ item_pager_image.xml

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android=“http://schemas.android.com/apk/res/android”

android:layout_width=“fill_parent”

android:layout_height=“fill_parent”

android:padding=“1dip” >

<ImageView

android:id="@+id/image"

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_gravity=“center”

android:adjustViewBounds=“true”

android:contentDescription="@string/descr_image" />

<ProgressBar

android:id="@+id/loading"

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_gravity=“center”

android:visibility=“gone” />

Gallery画廊异步加载图片显示

**/2013.8.19_Universal_Image_Loader_Demo/res/layout/ac_image_gallery.xml

**

<?xml version="1.0" encoding="utf-8"?>

<Gallery xmlns:android=“http://schemas.android.com/apk/res/android”

android:id="@+id/gallery"

android:layout_width=“fill_parent”

android:layout_height=“wrap_content”

android:layout_gravity=“center_vertical”

android:spacing=“1dip” />

/2013.8.19_Universal_Image_Loader_Demo/res/layout/item_gallery_image.xml

<?xml version="1.0" encoding="utf-8"?>

<ImageView xmlns:android=“http://schemas.android.com/apk/res/android”

android:id="@+id/image"

android:layout_width=“120dip”

android:layout_height=“120dip”

android:layout_gravity=“center”

android:adjustViewBounds=“true”

android:contentDescription="@string/descr_image"

android:scaleType=“centerCrop” />

还有一个就是桌面小部件

以上只是布局文件,没有什么可以说,具体Activity代码实现如下:

先是这个:

/2013.8.19_Universal_Image_Loader_Demo/src/com/nostra13/example/universalimageloader/HomeActivity.java

主界面Activity代码

/*******************************************************************************

  • Copyright 2011-2013 Sergey Tarasevich

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • http://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

*******************************************************************************/

package com.nostra13.example.universalimageloader;

import static com.nostra13.example.universalimageloader.Constants.IMAGES;

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStream;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import com.nostra13.example.universalimageloader.Constants.Extra;

import com.nostra13.universalimageloader.utils.L;

/**

  • @author Sergey Tarasevich (nostra13[at]gmail[dot]com)

*/

public class HomeActivity extends BaseActivity {

private static final String TEST_FILE_NAME = “Universal Image Loader @#&=±_.,!()~’%20.png”;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.ac_home);

// 定义文件对象,目录:/mnt/sdcard, 文件名:TEST_FILE_NAME

File testImageOnSdCard = new File("/mnt/sdcard", TEST_FILE_NAME);

if (!testImageOnSdCard.exists()) { // 如果文件不存在

// 把文件复制到SD卡

copyTestImageToSdCard(testImageOnSdCard);

}

}

// 点击进入ListView展示界面

public void onImageListClick(View view) {

Intent intent = new Intent(this, ImageListActivity.class);

intent.putExtra(Extra.IMAGES, IMAGES);

startActivity(intent);

}

// 点击进入GridView展示界面

public void onImageGridClick(View view) {

Intent intent = new Intent(this, ImageGridActivity.class);

intent.putExtra(Extra.IMAGES, IMAGES);

startActivity(intent);

}

// 点击进入ViewPager展示界面

public void onImagePagerClick(View view) {

Intent intent = new Intent(this, ImagePagerActivity.class);

intent.putExtra(Extra.IMAGES, IMAGES);

startActivity(intent);

}

// 点击进入画廊展示界面

public void onImageGalleryClick(View view) {

Intent intent = new Intent(this, ImageGalleryActivity.class);

intent.putExtra(Extra.IMAGES, IMAGES);

startActivity(intent);

}

@Override

public void onBackPressed() {

imageLoader.stop(); // 停止加载图片

super.onBackPressed();

}

/**

  • 开一个线程把assert目录下的图片复制到SD卡目录下

  • @param testImageOnSdCard

*/

private void copyTestImageToSdCard(final File testImageOnSdCard) {

new Thread(new Runnable() {

@Override

public void run() {

try {

InputStream is = getAssets().open(TEST_FILE_NAME);

FileOutputStream fos = new FileOutputStream(testImageOnSdCard);

byte[] buffer = new byte[8192];

int read;

try {

while ((read = is.read(buffer)) != -1) {

fos.write(buffer, 0, read); // 写入输出流

}

} finally {

fos.flush(); // 写入SD卡

fos.close(); // 关闭输出流

is.close(); // 关闭输入流

}

} catch (IOException e) {

L.w(“Can’t copy test image onto SD card”);

}

}

}).start(); // 启动线程

}

}

/2013.8.19_Universal_Image_Loader_Demo/src/com/nostra13/example/universalimageloader/ BaseActivity.java

/*******************************************************************************

  • Copyright 2011-2013 Sergey Tarasevich

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • http://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

*******************************************************************************/

package com.nostra13.example.universalimageloader;

import android.app.Activity;

import android.view.Menu;

import android.view.MenuItem;

import com.nostra13.universalimageloader.core.ImageLoader;

/**

  • @author Sergey Tarasevich (nostra13[at]gmail[dot]com)

*/

public abstract class BaseActivity extends Activity {

protected ImageLoader imageLoader = ImageLoader.getInstance();

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// 加载菜单

getMenuInflater().inflate(R.menu.main_menu, menu);

return true;

}

@Override

public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {

case R.id.item_clear_memory_cache:

imageLoader.clearMemoryCache(); // 清除内存缓存

return true;

case R.id.item_clear_disc_cache:

imageLoader.clearDiscCache(); // 清除SD卡中的缓存

return true;

default:

return false;

}

}

}

/2013.8.19_Universal_Image_Loader_Demo/src/com/nostra13/example/universalimageloader/AbsListViewBaseActivity.java

/*******************************************************************************

  • Copyright 2011-2013 Sergey Tarasevich

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • http://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

*******************************************************************************/

package com.nostra13.example.universalimageloader;

import android.os.Bundle;

import android.view.Menu;

import android.view.MenuItem;

import android.widget.AbsListView;

import com.nostra13.universalimageloader.core.assist.PauseOnScrollListener;

/**

  • @author Sergey Tarasevich (nostra13[at]gmail[dot]com)

*/

public class AbsListViewBaseActivity extends BaseActivity {

protected static final String STATE_PAUSE_ON_SCROLL = “STATE_PAUSE_ON_SCROLL”;

protected static final String STATE_PAUSE_ON_FLING = “STATE_PAUSE_ON_FLING”;

protected AbsListView listView;

protected boolean pauseOnScroll = false;

protected boolean pauseOnFling = true;

@Override

public void onRestoreInstanceState(Bundle savedInstanceState) {

pauseOnScroll = savedInstanceState.getBoolean(STATE_PAUSE_ON_SCROLL, false);

pauseOnFling = savedInstanceState.getBoolean(STATE_PAUSE_ON_FLING, true);

}

@Override

public void onResume() {

super.onResume();

applyScrollListener();

}

private void applyScrollListener() {

listView.setOnScrollListener(new PauseOnScrollListener(imageLoader, pauseOnScroll, pauseOnFling));

}

@Override

public void onSaveInstanceState(Bundle outState) {

outState.putBoolean(STATE_PAUSE_ON_SCROLL, pauseOnScroll);

outState.putBoolean(STATE_PAUSE_ON_FLING, pauseOnFling);

}

@Override

public boolean onPrepareOptionsMenu(Menu menu) {

MenuItem pauseOnScrollItem = menu.findItem(R.id.item_pause_on_scroll);

pauseOnScrollItem.setVisible(true);

pauseOnScrollItem.setChecked(pauseOnScroll);

MenuItem pauseOnFlingItem = menu.findItem(R.id.item_pause_on_fling);

pauseOnFlingItem.setVisible(true);

pauseOnFlingItem.setChecked(pauseOnFling);

return true;

}

@Override

public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {

case R.id.item_pause_on_scroll:

pauseOnScroll = !pauseOnScroll;

item.setChecked(pauseOnScroll);

applyScrollListener();

return true;

case R.id.item_pause_on_fling:

pauseOnFling = !pauseOnFling;

item.setChecked(pauseOnFling);

applyScrollListener();

return true;

default:

return super.onOptionsItemSelected(item);

}

}

}

/2013.8.19_Universal_Image_Loader_Demo/src/com/nostra13/example/universalimageloader/Constants.java

常量类代码

/*******************************************************************************

  • Copyright 2011-2013 Sergey Tarasevich

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • http://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

*******************************************************************************/

package com.nostra13.example.universalimageloader;

/**

  • @author Sergey Tarasevich (nostra13[at]gmail[dot]com)

  • 常量类

*/

public final class Constants {

// 一堆图片链接

public static final String[] IMAGES = new String[] {

// Heavy images

“https://lh6.googleusercontent.com/-jZgveEqb6pg/T3R4kXScycI/AAAAAAAAAE0/xQ7CvpfXDzc/s1024/sample_image_01.jpg”,

“https://lh4.googleusercontent.com/-K2FMuOozxU0/T3R4lRAiBTI/AAAAAAAAAE8/a3Eh9JvnnzI/s1024/sample_image_02.jpg”,

“https://lh5.googleusercontent.com/-SCS5C646rxM/T3R4l7QB6xI/AAAAAAAAAFE/xLcuVv3CUyA/s1024/sample_image_03.jpg”,

“https://lh6.googleusercontent.com/-f0NJR6-_Thg/T3R4mNex2wI/AAAAAAAAAFI/45oug4VE8MI/s1024/sample_image_04.jpg”,

“https://lh3.googleusercontent.com/-n-xcJmiI0pg/T3R4mkSchHI/AAAAAAAAAFU/EoiNNb7kk3A/s1024/sample_image_05.jpg”,

“https://lh3.googleusercontent.com/-X43vAudm7f4/T3R4nGSChJI/AAAAAAAAAFk/3bna6D-2EE8/s1024/sample_image_06.jpg”,

“https://lh5.googleusercontent.com/-MpZneqIyjXU/T3R4nuGO1aI/AAAAAAAAAFg/r09OPjLx1ZY/s1024/sample_image_07.jpg”,

“https://lh6.googleusercontent.com/-ql3YNfdClJo/T3XvW9apmFI/AAAAAAAAAL4/_6HFDzbahc4/s1024/sample_image_08.jpg”,

“https://lh5.googleusercontent.com/-Pxa7eqF4cyc/T3R4oasvPEI/AAAAAAAAAF0/-uYDH92h8LA/s1024/sample_image_09.jpg”,

“https://lh4.googleusercontent.com/-Li-rjhFEuaI/T3R4o-VUl4I/AAAAAAAAAF8/5E5XdMnP1oE/s1024/sample_image_10.jpg”,

“https://lh5.googleusercontent.com/-_HU4fImgFhA/T3R4pPVIwWI/AAAAAAAAAGA/0RfK_Vkgth4/s1024/sample_image_11.jpg”,

“https://lh6.googleusercontent.com/-0gnNrVjwa0Y/T3R4peGYJwI/AAAAAAAAAGU/uX_9wvRPM9I/s1024/sample_image_12.jpg”,

“https://lh3.googleusercontent.com/-HBxuzALS_Zs/T3R4qERykaI/AAAAAAAAAGQ/_qQ16FaZ1q0/s1024/sample_image_13.jpg”,

“https://lh4.googleusercontent.com/-cKojDrARNjQ/T3R4qfWSGPI/AAAAAAAAAGY/MR5dnbNaPyY/s1024/sample_image_14.jpg”,

“https://lh3.googleusercontent.com/-WujkdYfcyZ8/T3R4qrIMGUI/AAAAAAAAAGk/277LIdgvnjg/s1024/sample_image_15.jpg”,

“https://lh6.googleusercontent.com/-FMHR7Vy3PgI/T3R4rOXlEKI/AAAAAAAAAGs/VeXrDNDBkaw/s1024/sample_image_16.jpg”,

“https://lh4.googleusercontent.com/-mrR0AJyNTH0/T3R4rZs6CuI/AAAAAAAAAG0/UE1wQqCOqLA/s1024/sample_image_17.jpg”,

“https://lh6.googleusercontent.com/-z77w0eh3cow/T3R4rnLn05I/AAAAAAAAAG4/BaerfWoNucU/s1024/sample_image_18.jpg”,

“https://lh5.googleusercontent.com/-aWVwh1OU5Bk/T3R4sAWw0yI/AAAAAAAAAHE/4_KAvJttFwA/s1024/sample_image_19.jpg”,

“https://lh6.googleusercontent.com/-q-js52DMnWQ/T3R4tZhY2sI/AAAAAAAAAHM/A8kjp2Ivdqg/s1024/sample_image_20.jpg”,

“https://lh5.googleusercontent.com/-_jIzvvzXKn4/T3R4t7xpdVI/AAAAAAAAAHU/7QC6eZ10jgs/s1024/sample_image_21.jpg”,

“https://lh3.googleusercontent.com/-lnGi4IMLpwU/T3R4uCMa7vI/AAAAAAAAAHc/1zgzzz6qTpk/s1024/sample_image_22.jpg”,

“https://lh5.googleusercontent.com/-fFCzKjFPsPc/T3R4u0SZPFI/AAAAAAAAAHk/sbgjzrktOK0/s1024/sample_image_23.jpg”,

“https://lh4.googleusercontent.com/-8TqoW5gBE_Y/T3R4vBS3NPI/AAAAAAAAAHs/EZYvpNsaNXk/s1024/sample_image_24.jpg”,

“https://lh6.googleusercontent.com/-gc4eQ3ySdzs/T3R4vafoA7I/AAAAAAAAAH4/yKii5P6tqDE/s1024/sample_image_25.jpg”,

“https://lh5.googleusercontent.com/–NYOPCylU7Q/T3R4vjAiWkI/AAAAAAAAAH8/IPNx5q3ptRA/s1024/sample_image_26.jpg”,

“https://lh6.googleusercontent.com/-9IJM8so4vCI/T3R4vwJO2yI/AAAAAAAAAIE/ljlr-cwuqZM/s1024/sample_image_27.jpg”,

“https://lh4.googleusercontent.com/-KW6QwOHfhBs/T3R4w0RsQiI/AAAAAAAAAIM/uEFLVgHPFCk/s1024/sample_image_28.jpg”,

“https://lh4.googleusercontent.com/-z2557Ec1ctY/T3R4x3QA2hI/AAAAAAAAAIk/9-GzPL1lTWE/s1024/sample_image_29.jpg”,

“https://lh5.googleusercontent.com/-LaKXAn4Kr1c/T3R4yc5b4lI/AAAAAAAAAIY/fMgcOVQfmD0/s1024/sample_image_30.jpg”,

“https://lh4.googleusercontent.com/-F9LRToJoQdo/T3R4yrLtyQI/AAAAAAAAAIg/ri9uUCWuRmo/s1024/sample_image_31.jpg”,

“https://lh4.googleusercontent.com/-6X-xBwP-QpI/T3R4zGVboII/AAAAAAAAAIs/zYH4PjjngY0/s1024/sample_image_32.jpg”,

“https://lh5.googleusercontent.com/-VdLRjbW4LAs/T3R4zXu3gUI/AAAAAAAAAIw/9aFp9t7mCPg/s1024/sample_image_33.jpg”,

“https://lh6.googleusercontent.com/-gL6R17_fDJU/T3R4zpIXGjI/AAAAAAAAAI8/Q2Vjx-L9X20/s1024/sample_image_34.jpg”,

“https://lh3.googleusercontent.com/-1fGH4YJXEzo/T3R40Y1B7KI/AAAAAAAAAJE/MnTsa77g-nk/s1024/sample_image_35.jpg”,

“https://lh4.googleusercontent.com/-Ql0jHSrea-A/T3R403mUfFI/AAAAAAAAAJM/qzI4SkcH9tY/s1024/sample_image_36.jpg”,

“https://lh5.googleusercontent.com/-BL5FIBR_tzI/T3R41DA0AKI/AAAAAAAAAJk/GZfeeb-SLM0/s1024/sample_image_37.jpg”,

“https://lh4.googleusercontent.com/-wF2Vc9YDutw/T3R41fR2BCI/AAAAAAAAAJc/JdU1sHdMRAk/s1024/sample_image_38.jpg”,

“https://lh6.googleusercontent.com/-ZWHiPehwjTI/T3R41zuaKCI/AAAAAAAAAJg/hR3QJ1v3REg/s1024/sample_image_39.jpg”,

// Light images

“http://tabletpcssource.com/wp-content/uploads/2011/05/android-logo.png”,

“http://simpozia.com/pages/images/stories/windows-icon.png”,

“https://si0.twimg.com/profile_images/1135218951/gmail_profile_icon3_normal.png”,

“http://www.krify.net/wp-content/uploads/2011/09/Macromedia_Flash_dock_icon.png”,

“http://radiotray.sourceforge.net/radio.png”,

“http://www.bandwidthblog.com/wp-content/uploads/2011/11/twitter-logo.png”,

“http://weloveicons.s3.amazonaws.com/icons/100907_itunes1.png”,

“http://weloveicons.s3.amazonaws.com/icons/100929_applications.png”,

“http://www.idyllicmusic.com/index_files/get_apple-iphone.png”,

“http://www.frenchrevolutionfood.com/wp-content/uploads/2009/04/Twitter-Bird.png”,

“http://3.bp.blogspot.com/-ka5MiRGJ_S4/TdD9OoF6bmI/AAAAAAAAE8k/7ydKtptUtSg/s1600/Google_Sky%2BMaps_Android.png”,

“http://www.desiredsoft.com/images/icon_webhosting.png”,

“http://goodereader.com/apps/wp-content/uploads/downloads/thumbnails/2012/01/hi-256-0-99dda8c730196ab93c67f0659d5b8489abdeb977.png”,

“http://1.bp.blogspot.com/-mlaJ4p_3rBU/TdD9OWxN8II/AAAAAAAAE8U/xyynWwr3_4Q/s1600/antivitus_free.png”,

“http://cdn3.iconfinder.com/data/icons/transformers/computer.png”,

“http://cdn.geekwire.com/wp-content/uploads/2011/04/firefox.png?7794fe”,

“https://ssl.gstatic.com/android/market/com.rovio.angrybirdsseasons/hi-256-9-347dae230614238a639d21508ae492302340b2ba”,

“http://androidblaze.com/wp-content/uploads/2011/12/tablet-pc-256x256.jpg”,

“http://www.theblaze.com/wp-content/uploads/2011/08/Apple.png”,

“http://1.bp.blogspot.com/-y-HQwQ4Kuu0/TdD9_iKIY7I/AAAAAAAAE88/3G4xiclDZD0/s1600/Twitter_Android.png”,

“http://3.bp.blogspot.com/-nAf4IMJGpc8/TdD9OGNUHHI/AAAAAAAAE8E/VM9yU_lIgZ4/s1600/Adobe%2BReader_Android.png”,

“http://cdn.geekwire.com/wp-content/uploads/2011/05/oovoo-android.png?7794fe”,

“http://icons.iconarchive.com/icons/kocco/ndroid/128/android-market-2-icon.png”,

“http://thecustomizewindows.com/wp-content/uploads/2011/11/Nicest-Android-Live-Wallpapers.png”,

“http://c.wrzuta.pl/wm16596/a32f1a47002ab3a949afeb4f”,

“http://macprovid.vo.llnwd.net/o43/hub/media/1090/6882/01_headline_Muse.jpg”,

// Special cases

“http://cdn.urbanislandz.com/wp-content/uploads/2011/10/MMSposter-large.jpg”, // very large image

“file:///sdcard/Universal Image Loader @#&=±_.,!()~’%20.png”, // Image from SD card with encoded symbols

“assets://Living Things @#&=±_.,!()~’%20.jpg”, // Image from assets

“drawable://” + R.drawable.ic_launcher, // Image from drawables

“http://upload.wikimedia.org/wikipedia/ru/b/b6/袣邪泻_泻芯褌_褋_屑褘褕邪屑懈_胁芯械胁邪谢.png”, // Link with UTF-8

“https://www.eff.org/sites/default/files/chrome150_0.jpg”, // Image from HTTPS

“http://bit.ly/soBiXr”, // Redirect link

“http://img001.us.expono.com/100001/100001-1bc30-2d736f_m.jpg”, // EXIF

“”, // Empty link

“http://wrong.site.com/corruptedLink”, // Wrong link

};

private Constants() {

}

// 配置

public static class Config {

public static final boolean DEVELOPER_MODE = false;

}

// 额外类

public static class Extra {

public static final String IMAGES = “com.nostra13.example.universalimageloader.IMAGES”;

public static final String IMAGE_POSITION = “com.nostra13.example.universalimageloader.IMAGE_POSITION”;

}

}

/2013.8.19_Universal_Image_Loader_Demo/src/com/nostra13/example/universalimageloader/ImageListActivity.java

/*******************************************************************************

  • Copyright 2011-2013 Sergey Tarasevich

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • http://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

*******************************************************************************/

package com.nostra13.example.universalimageloader;

import java.util.Collections;

import java.util.LinkedList;

import java.util.List;

import android.content.Intent;

import android.graphics.Bitmap;

import android.os.Bundle;

import android.view.View;

import android.view.ViewGroup;

import android.widget.AdapterView;

import android.widget.AdapterView.OnItemClickListener;

import android.widget.BaseAdapter;

import android.widget.ImageView;

import android.widget.ListView;

import android.widget.TextView;

import com.nostra13.example.universalimageloader.Constants.Extra;

import com.nostra13.universalimageloader.core.DisplayImageOptions;

import com.nostra13.universalimageloader.core.assist.ImageLoadingListener;

import com.nostra13.universalimageloader.core.assist.SimpleImageLoadingListener;

import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;

import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;

/**

  • @author Sergey Tarasevich (nostra13[at]gmail[dot]com)

*/

public class ImageListActivity extends AbsListViewBaseActivity {

DisplayImageOptions options; // DisplayImageOptions是用于设置图片显示的类

String[] imageUrls; // 图片路径

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.ac_image_list);

Bundle bundle = getIntent().getExtras();

imageUrls = bundle.getStringArray(Extra.IMAGES);

// 使用DisplayImageOptions.Builder()创建DisplayImageOptions

options = new DisplayImageOptions.Builder()

.showStubImage(R.drawable.ic_stub) // 设置图片下载期间显示的图片

.showImageForEmptyUri(R.drawable.ic_empty) // 设置图片Uri为空或是错误的时候显示的图片

.showImageOnFail(R.drawable.ic_error) // 设置图片加载或解码过程中发生错误显示的图片

.cacheInMemory(true) // 设置下载的图片是否缓存在内存中

.cacheOnDisc(true) // 设置下载的图片是否缓存在SD卡中

.displayer(new RoundedBitmapDisplayer(20)) // 设置成圆角图片

.build(); // 创建配置过得DisplayImageOption对象

listView = (ListView) findViewById(android.R.id.list);

((ListView) listView).setAdapter(new ItemAdapter());

listView.setOnItemClickListener(new OnItemClickListener() {

@Override

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

// 点击列表项转入ViewPager显示界面

startImagePagerActivity(position);

}

});

}

@Override

public void onBackPressed() {

AnimateFirstDisplayListener.displayedImages.clear();

super.onBackPressed();

}

private void startImagePagerActivity(int position) {

Intent intent = new Intent(this, ImagePagerActivity.class);

intent.putExtra(Extra.IMAGES, imageUrls);

intent.putExtra(Extra.IMAGE_POSITION, position);

startActivity(intent);

}

/**

  • 自定义列表项适配器

*/

class ItemAdapter extends BaseAdapter {

private ImageLoadingListener animateFirstListener = new AnimateFirstDisplayListener();

private class ViewHolder {

public TextView text;

public ImageView image;

}

@Override

public int getCount() {

return imageUrls.length;

}

@Override

public Object getItem(int position) {

return position;

}

@Override

public long getItemId(int position) {

return position;

}

@Override

public View getView(final int position, View convertView, ViewGroup parent) {

View view = convertView;

final ViewHolder holder;

if (convertView == null) {

view = getLayoutInflater().inflate(R.layout.item_list_image, parent, false);

holder = new ViewHolder();

holder.text = (TextView) view.findViewById(R.id.text);

holder.image = (ImageView) view.findViewById(R.id.image);

view.setTag(holder); // 给View添加一个格外的数据

} else {

holder = (ViewHolder) view.getTag(); // 把数据取出来

}

holder.text.setText("Item " + (position + 1)); // TextView设置文本

尾声

最后,我再重复一次,如果你想成为一个优秀的 Android 开发人员,请集中精力,对基础和重要的事情做深度研究。

对于很多初中级Android工程师而言,想要提升技能,往往是自己摸索成长,不成体系的学习效果低效漫长且无助。 整理的这些架构技术希望对Android开发的朋友们有所参考以及少走弯路,本文的重点是你有没有收获与成长,其余的都不重要,希望读者们能谨记这一点。

最后想要拿高薪实现技术提升薪水得到质的飞跃。最快捷的方式,就是有人可以带着你一起分析,这样学习起来最为高效,所以为了大家能够顺利进阶中高级、架构师,我特地为大家准备了一套高手学习的源码和框架视频等精品Android架构师教程,保证你学了以后保证薪资上升一个台阶。

当你有了学习线路,学习哪些内容,也知道以后的路怎么走了,理论看多了总要实践的。

进阶学习视频

附上:我们之前因为秋招收集的二十套一二线互联网公司Android面试真题 (含BAT、小米、华为、美团、滴滴)和我自己整理Android复习笔记(包含Android基础知识点、Android扩展知识点、Android源码解析、设计模式汇总、Gradle知识点、常见算法题汇总。)

imateFirstListener = new AnimateFirstDisplayListener();

private class ViewHolder {

public TextView text;

public ImageView image;

}

@Override

public int getCount() {

return imageUrls.length;

}

@Override

public Object getItem(int position) {

return position;

}

@Override

public long getItemId(int position) {

return position;

}

@Override

public View getView(final int position, View convertView, ViewGroup parent) {

View view = convertView;

final ViewHolder holder;

if (convertView == null) {

view = getLayoutInflater().inflate(R.layout.item_list_image, parent, false);

holder = new ViewHolder();

holder.text = (TextView) view.findViewById(R.id.text);

holder.image = (ImageView) view.findViewById(R.id.image);

view.setTag(holder); // 给View添加一个格外的数据

} else {

holder = (ViewHolder) view.getTag(); // 把数据取出来

}

holder.text.setText("Item " + (position + 1)); // TextView设置文本

尾声

最后,我再重复一次,如果你想成为一个优秀的 Android 开发人员,请集中精力,对基础和重要的事情做深度研究。

对于很多初中级Android工程师而言,想要提升技能,往往是自己摸索成长,不成体系的学习效果低效漫长且无助。 整理的这些架构技术希望对Android开发的朋友们有所参考以及少走弯路,本文的重点是你有没有收获与成长,其余的都不重要,希望读者们能谨记这一点。

最后想要拿高薪实现技术提升薪水得到质的飞跃。最快捷的方式,就是有人可以带着你一起分析,这样学习起来最为高效,所以为了大家能够顺利进阶中高级、架构师,我特地为大家准备了一套高手学习的源码和框架视频等精品Android架构师教程,保证你学了以后保证薪资上升一个台阶。

当你有了学习线路,学习哪些内容,也知道以后的路怎么走了,理论看多了总要实践的。

进阶学习视频

[外链图片转存中…(img-ysdBXYCr-1643868555898)]

附上:我们之前因为秋招收集的二十套一二线互联网公司Android面试真题 (含BAT、小米、华为、美团、滴滴)和我自己整理Android复习笔记(包含Android基础知识点、Android扩展知识点、Android源码解析、设计模式汇总、Gradle知识点、常见算法题汇总。)

[外链图片转存中…(img-gZGhc4uz-1643868555899)]

本文已被CODING开源项目:《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》收录

vue3 - 详细实现内网使用离线高德地图功能,在vue3中无需网络离线使用高德地图相关功能,高德地图如何离线加载详细教程(内网部署及使用),提供最新完整的瓦片资源下载及相关工具(示例代码,一键复制) vue3,高德地图,离线使用高德地图,高德地图瓦片官方下载,内网使用高德地图离线无网络,断网情况下使用高德地图,vue离线高德地图教程,内网部署高德地图,无需联网离线使用,vue3+ts实现离线高德地图 内网离线高德地图,如何在高德地图Vue3项目中下载离线地图,地图加载不出来,不显示怎么办,内网使用离线高德地图加载失败问题,vue3实现离线地图+高德瓦片,vue3高德离线地图,如何使用离线高德地图和自定义地图样式,高德离线地图的下载,怎么下载高德地图瓦片,一键把所有瓦片都下载下来,离线加载,内网部署,离线 阅读详情

相关推荐

universal-image-loader-1.9.5最新版本

Android Studio universal-image-loader-1.9.5 最新版本 import com.nostra13.universalimageloader https://github.com/nostra13/Android-Universal-Image-Loader/blob/master/downloads/universal-image-loader-1.9.5.jar

Android开源框架Universal-Image-Loader详解

如果说评价一下哪个图片开源库最被广泛使用的话,我想应该可以说是Universal-Image-Loader,在主流的应用中如 果你随便去反编译几个,基本都能看到他的身影,它就像个图片加载守护者,默默的守护着图片加载。相信很多人对 这个异步加载图片框架还不是很熟,再加上最近它更改优化了好几个地方,而网上的大部分资料还是以前的,于是花 了几天时间专门的研究了下开源框架Universal-Imag

梦痕的专栏 6572

计算机视觉_边缘检测_轮廓检测_Hough直线变换_二值分割_形态学处理_图像旋转_文档扫描优化_自动切边_法律文件处理_基于OpenCV的智能文档扫描边缘检测与自动校正系统_用于法律文件电子.zip

计算机视觉_边缘检测_轮廓检测_Hough直线变换_二值分割_形态学处理_图像旋转_文档扫描优化_自动切边_法律文件处理_基于OpenCV的智能文档扫描边缘检测与自动校正系统_用于法律文件电子.zip

com.nostra13.example.universalimageloader的使用

相信大家平时做Android应用的时候,多少会接触到异步加载图片,或者加载大量图片的问题,而加载图片我们常常会遇到许多的问题,比如说图片的错乱,OOM等问题,对于新手来说,这些问题解决起来会比较吃力,所以就有很多的开源图片加载框架应运而生,比较著名的就是Universal-Image-Loader,相信很多朋友都听过或者使用过这个强大的图片加载框架,今天这篇文章就是对这个框架的基本介绍以及使用,主

chong7171的专栏 3206

Android之com.nostra13.universalimageloader加载图片抛出OutOfMemroyError错误的多种解决办法...

com.nostra13.universalimageloader是用来加载图片非常好的框架,但是也有问题,一旦图片过多的话,很容易就会提示OutOfMemroyError错误,也就是内存溢出的问题,在这里有几种解决办法,可以参考下。 一、减少图片占用的内存 对DisplayImageOptions类使用如下的配置。 1 new DisplayImageOptions.Builder()...

weixin_30823683的博客 550

com.nostra13.universalimageloader.core.ImageLoaderimageloader在ViewPager中的用法记录

1.application初始化 public class MApplication extends Application {     private static Editor editor;     private static SharedPreferences sp;     private static DecimalFormat format;          

xiejunna的博客 3484

Android框架UniversalImageLoader

Android开源框架ImageLoader完美例子 2013年8月19日开源框架之Universal_Image_Loader学习 很多人都在讨论如何让图片能在异步加载更加流畅,可以显示大量图片,在拖动ListView的时候不会出现卡的现象。关于ImageLoader这个开源框架的使用有很多网友都介绍过,不过还不够清楚,这里有一个关于这个开源项目的完美例子,ListView

随意而然的专栏 1226

Android UI-开源框架ImageLoader完美例子,字节跳动Andorid岗25k+的面试

外链图片转存中…(img-hFAsK3xZ-1712345981702)][外链图片转存中…(img-YH15ERn7-1712345981702)][外链图片转存中…(img-QMiL3UG5-1712345981703)][外链图片转存中…(img-ll1bqu9M-1712345981703)][外链图片转存中…(img-sAZv0JpG-1712345981703)]

2401_84149855的博客 4362

安卓工程面试问题,2024非科班生的Android秋招(1),推荐给大家

2.OkHttp4.LinearLayout和RelativeLayout的区别,优缺点,层级嵌套等等等5.ConstrantLayout讲讲特点6.性能优化在中做过哪些7.读过哪些Android的8.BroadCastReceiver的看过么?9.FrameLayout了解么?

m0_74931167的博客 992

Android从初级到中级,记录一次Android面试

最后为了帮助大家深刻理解Android相关知识点的原理以及面试相关知识,这里放上相关的我搜集整理的Android开发中高级必知必会核心笔记,共计2968页PDF、58w字,囊括Android开发648个知识点,我把技术点整理成了视频和PDF(实际上比预期多花了不少精力),包知识脉络 + 诸多细节。网上学习 Android的资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。希望这份系统化的技术体系对大家有一个方向参考。

2401_84121588的博客 811

2024字节跳动,金三银四内幕Android中高级面试题合集-令人细思极恐!

这里只简单列举一些东西,可能不是特别全,但是却特别适用,也不一定按照下面的流程,有可能是穿插的,也有可能都有,根据公司的规模以及面试官的心情而定(哈哈哈 ,你们就自求多福吧)。建议大家还是要将下面的东西全部掌握,没事写写代码,练练手,在项目中能用到的地方一定要用,有可能会遇到很多坑,一定要自己想办法填坑,之后回忆起这段经历,肯定可以敢理直气壮的跟别人讨论。如果你说的头头是道,那么对方会先输一层,然后在心里对你佩服。1.一般情况下第一轮都是基础面试,需要扎实的基础最常用的Android 基础知识。

2301_79098686的博客 636

Android快速集成框架:MVP+Dagger+主流框架

相关阅读: 吊炸天!74款APP完整源码! [干货]2017已来,最全面试总结——这些Android面试题你一定需要 Android常用开源框架的源码解读套路--教你怎么读开源框架源码 公众号:Java和Android架构 关注回复:Android,iOS,PHP,js,HTML5,Python,Hadoop,c++,J2EE等关键字就

AMEPRE88的博客 1408

Android UI-开源框架ImageLoader完美例子

现在新技术层出不穷,如果每次出新的技术,我们都深入的研究的话,很容易分散精力。新的技术可能很久之后我们才会在工作中用得上,当学的新技术无法学以致用,很容易被我们遗忘,到最后真的需要使用的时候,又要从头来过(虽然上手会更快)。我觉得身为技术人,针对新技术应该是持拥抱态度的,入了这一行你就应该知道这是一个活到老学到老的行业,所以面对新技术,不要抵触,拥抱变化就好了。Flutter 明显是一种全新的技术,而对于这个新技术在发布之初,花一个月的时间学习它,成本确实过高。

2401_84008929的博客 799

分析com.nostra13.universalimageloader

ImageLoaderConfiguration类 这个类主要说一下build()方法里面的initEmptyFiledsWithDefaultValues()方法 这里面主要确定了两件事 1.线程池中的队列用的是QueueProcessingType中的先进先出FIFO还是后进先出LIFO见DefaultConfigurationFactory /**   * 创建线程池   *

679

Android图片异步加载框架Android-Universal-Image-Loader

1、加载图片之前,先要做初始化配置,这个类似很多游戏引擎使用前要做一下初始化,其实只做了一件事,实例化一个全局的ImageLoader对象,同时传入图片加载缓存的配置,ImageLoaderConfiguration封装了基本的配置信息,比如加载图片事用的线程池大小,线程的优先级,内存缓存大小,是否支持同一图片的多尺寸缓存(默认是支持的,可以手动关闭),还有缓存的命名规则等等。代码语言:javascript。代码语言:javascript。代码语言:javascript。代码语言:javascript。

u013641294的博客 634

Android开源框架Universal-Image-Loader应用

概述 Universal-Image-Loader是一个使用非常广泛的异步加载图片的开源库,目前手中的项目正好是使用这个开源库,为了能更好的应用该开源库的知识点,也让自己能够理解的更加深刻,现在自己写下这篇博客进行总结,记录自己的学习体会;

yuminfeng728的博客 543
上一篇: Android UI--开源项目IndexableListView(字母索引),万分膜拜
下一篇: Android View双缓冲绘制下不符合逻辑的刷新机制,kotlin开发安卓游戏
wa2231a
博客等级 码龄5年 7粉丝 205原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值