最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android之使用Android-query框架開發(fā)實(shí)戰(zhàn)(一)

 更新時(shí)間:2015年10月08日 10:58:54   作者:lee0oo0  
這篇文章主要介紹了Android之使用Android-query框架開發(fā)實(shí)戰(zhàn)(一)的相關(guān)資料,需要的朋友可以參考下

開發(fā)Android使用Android-query框架能夠快速的,比傳統(tǒng)開發(fā)android所要編寫的代碼要少得很多,容易閱讀等優(yōu)勢(shì)。 

下載文檔及其例子和包的地址:http://code.google.com/p/android-query/

 以下內(nèi)容是我學(xué)習(xí)的一些心得分享:

第一節(jié):

// 必須實(shí)現(xiàn)AQuery這個(gè)類
 AQuery aq = new AQuery(view);
 // 按順序分析:取得xml對(duì)應(yīng)控件id,設(shè)置圖片,設(shè)置可以顯示,點(diǎn)擊事件(方法someMethod必須是public修飾) 
 aq.id(R.id.icon).image(R.drawable.icon).visible().clicked(this, "someMethod"); 
 // 設(shè)置文字內(nèi)容
  aq.id(R.id.name).text(content.getPname());
  aq.id(R.id.time).text(FormatUtility.relativeTime(System.currentTimeMillis(), content.getCreate())).visible();

 aq.id(R.id.desc).text(content.getDesc()).visible(); 

  AQuery也支持Fragment:

 @Override
 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
  View view = inflater.inflate(getContainerView(), container, false);    
    
  aq = new AQuery(getActivity(), view);
  return view;
 } 
  

第二節(jié): 使用AQuery異步加載圖片

2.1 從網(wǎng)上讀取圖片

 aq.id(R.id.image1).image(“圖片URL”);

2.2 緩存控制:  圖片過(guò)大的話,避免記憶緩存

 boolean memCache = false;
     boolean fileCache = true;
     aq.id(R.id.image1).image("

2.3 當(dāng)下載太多圖片的時(shí)候需要降低圖片采樣率,第四個(gè)參數(shù)為了保證圖片質(zhì)量,一般范圍時(shí)200-399

   aq.id(R.id.image1).image(imageUrl, true, true, 200, 0);

2.4 如果下載圖片失敗,處理的方法:1. 設(shè)置一個(gè)預(yù)定的圖片  2. 使imageview不可見或者是gone

     aq.id(R.id.image1).image(imageUrl, true, true, 0, R.drawable.default_image);
     aq.id(R.id.image1).image(imageUrl, true, true, 0, AQuery.INVISIBLE);
     aq.id(R.id.image1).image(imageUrl, true, true, 0, AQuery.GONE);

2.5 圖片預(yù)加載

    // 從之前的url取得小圖片
     String thumbnail = "
     Bitmap preset = aq.getCachedImage(thumbnail);
    // 加載大圖片前先顯示小圖片
     String imageUrl = "
    aq.id(R.id.image).image(imageUrl, false, false, 0, 0, preset, AQuery.FADE_IN);

2.6 在加載圖片的時(shí)候顯示進(jìn)度條,progress里面?zhèn)魅雐d

    String imageUrl = "      aq.id(R.id.image).progress(R.id.progress).image(imageUrl, false, false);

2.7 圖片圓角顯示,不支持大圖片

     ImageOptions options = new ImageOptions();
     options.round = 15;
     aq.id(R.id.image).image(url, options);

2.8 圖片長(zhǎng)寬比例   

    // 保留原圖片比例
    aq.id(R.id.image).image(imageUrl, true, true, 0, 0, null, AQuery.FADE_IN, AQuery.RATIO_PRESERVE);
    // 自定義圖片比例
    //1:1, a square
    aq.id(R.id.image2).image(imageUrl, true, true, 0, 0, null, 0, 1.0f / 1.0f);            
    aq.id(R.id.image3).image(imageUrl, true, true, 0, 0, null, 0, 1.5f / 1.0f);    
    //16:9, a video thumbnail
    aq.id(R.id.image4).image(imageUrl, true, true, 0, 0, null, 0, 9.0f / 16.0f);   
    aq.id(R.id.image5).image(imageUrl, true, true, 0, 0, null, 0, 3.0f / 4.0f);

2.9 圖片描點(diǎn),如果圖片過(guò)高,描點(diǎn)可用來(lái)描述圖片的哪一部分用于顯示

    Anchor values:
1.0 : Display top of the image
0 : Display the center of the image
-1.0 : Display bottom of the image
AQuery.ANCHOR_DYNAMIC : Display image with a top bias for photos.
=======================================================
 ImageOptions options = new ImageOptions();
 options.ratio = 1;
 options.anchor = 1.0;
 aq.id(R.id.image1).image(imageUrl, options);

2.10 自定義圖片加載后的處理

    aq.id(R.id.image1).image(imageUrl, true, true, 0, 0, new BitmapAjaxCallback(){});

2.11 異步從文件加載圖片,建議使用降低采樣率避免oom

 File file = new File(path);  
 //load image from file, down sample to target width of 300 pixels 
 aq.id(R.id.avatar).image(file, 300);
 //load image from file with callback
 aq.id(R.id.avatar).image(file, false, 300, new BitmapAjaxCallback(){
 @Override
 public void callback(String url, ImageView iv, Bitmap bm, AjaxStatus status){
  iv.setImageBitmap(bm);
 }
});

2.12 如果之前image("url")已經(jīng)成功,之后的都可以直接使用而不需要重新訪問(wèn)網(wǎng)絡(luò),也就是說(shuō)之后可以離線訪問(wèn)此圖像資源

2.13 文件中獲取緩沖圖片

     File file = aq.getCachedFile(url);

2.14 除了imageview,webview也可以用來(lái)放圖片

     aq.id(R.id.web).progress(R.id.progress).webImage(url);

2.15 延遲圖片加載,幫助你是否加載正在快速滾動(dòng)的listview,詳情參考文檔使用

2.16 圖片不使用緩存

     aq.id(R.id.image).image(url, false, false);

2.17 緩存配置,緩存一般是保存在內(nèi)部文件系統(tǒng),但也可以保存在SDCard里面

      File ext = Environment.getExternalStorageDirectory();
      File cacheDir = new File(ext, "myapp");
      AQUtility.setCacheDir(cacheDir);

2.18 共享圖片,為了與其他程序共享圖片,你需要把文件放在SDCard,makeSharedFile方法創(chuàng)建緩存地址的一個(gè)副本

 File file = aq.makeSharedFile(url, "android.png");
   if(file != null){
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("image/jpeg");
    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
    startActivityForResult(Intent.createChooser(intent, "Share via:"), SEND_REQUEST);
  }

2.19 配置,最好把配置寫在application的onCreate方法,詳細(xì)參考文檔

2.20 程序退出時(shí)候需要把緩存清除

  if(isTaskRoot()){
 AQUtility.cleanCacheAsync(this);
 }

 或者:

  if(isTaskRoot()){
 //clean the file cache with advance option
  long triggerSize = 3000000; //大于3M時(shí)候開始清除
  long targetSize = 2000000;  //直到少于2M
  AQUtility.cleanCacheAsync(this, triggerSize, targetSize);
  }

2.21 低內(nèi)存處理

  public class MainApplication extends Application{
   @Override
   public void onLowMemory(){ 
  //clear all memory cached images when system is in low memory
  //note that you can configure the max image cache count, see CONFIGURATION
   BitmapAjaxCallback.clearCache();
 }
}

以上內(nèi)容就是小編跟大家介紹的Android之使用Android-query框架開發(fā)實(shí)戰(zhàn)(一),希望大家喜歡,下篇文章跟大家介紹Android之使用Android-query框架開發(fā)實(shí)戰(zhàn)(二),感興趣的朋友請(qǐng)持續(xù)關(guān)注本站。

相關(guān)文章

  • Android通過(guò)ConnectivityManager檢查網(wǎng)絡(luò)狀態(tài)

    Android通過(guò)ConnectivityManager檢查網(wǎng)絡(luò)狀態(tài)

    這篇文章主要為大家詳細(xì)介紹了Android通過(guò)ConnectivityManager檢查網(wǎng)絡(luò)狀態(tài)的相關(guān)資料,感興趣的小伙伴們可以參考一下
    2016-08-08
  • 分享一個(gè)Android設(shè)置圓形圖片的特別方法

    分享一個(gè)Android設(shè)置圓形圖片的特別方法

    圓形圖片想必是項(xiàng)目開發(fā)中也是不少用的一個(gè)知識(shí)點(diǎn)吧。那么這里學(xué)習(xí)一下簡(jiǎn)單的制作圓形圖片,這個(gè)方法不用于平時(shí)的實(shí)現(xiàn)方法,有需要的可以參考借鑒。
    2016-09-09
  • Android Coil對(duì)比Glide深入分析探究

    Android Coil對(duì)比Glide深入分析探究

    這篇文章主要介紹了Android Coil對(duì)比Glide,Coil是Android上的一個(gè)全新的圖片加載框架,它的全名叫做coroutine image loader,即協(xié)程圖片加載庫(kù)
    2023-02-02
  • OkHttp3中默認(rèn)不保持Cookie的解決方法

    OkHttp3中默認(rèn)不保持Cookie的解決方法

    這篇文章主要給大家介紹了關(guān)于OkHttp3中默認(rèn)不保持Cookie的解決方法,文中先對(duì)OKhttp3中的cookies進(jìn)行了簡(jiǎn)單的介紹,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-04-04
  • Android文本視圖TextView實(shí)現(xiàn)聊天室效果

    Android文本視圖TextView實(shí)現(xiàn)聊天室效果

    這篇文章主要介紹了Android文本視圖TextView實(shí)現(xiàn)聊天室效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-05-05
  • Android重要控件SnackBar使用方法詳解

    Android重要控件SnackBar使用方法詳解

    這篇文章主要為大家詳細(xì)介紹了Android重要控件SnackBar使用方法,以及使用SnackBar的心得,感興趣的小伙伴們可以參考一下
    2016-07-07
  • Android仿google now效果的呼吸按鈕

    Android仿google now效果的呼吸按鈕

    這篇文章主要為大家詳細(xì)介紹了Android仿google now效果的呼吸按鈕簡(jiǎn)單實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-08-08
  • Android ListView在Fragment中的使用示例詳解

    Android ListView在Fragment中的使用示例詳解

    這篇文章主要介紹了Android ListView在Fragment中的使用,因?yàn)楣ぷ饕恢痹谟胢vvm框架,因此這篇文章是基于mvvm框架寫的,本文通過(guò)示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-09-09
  • Android實(shí)現(xiàn)簡(jiǎn)單的文件下載與上傳

    Android實(shí)現(xiàn)簡(jiǎn)單的文件下載與上傳

    今天小編就為大家分享一篇關(guān)于Android實(shí)現(xiàn)簡(jiǎn)單的文件下載與上傳,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2018-12-12
  • 詳解Android中Room組件的使用

    詳解Android中Room組件的使用

    Room 是在 SQLite 上提供了一個(gè)抽象層,以便在充分利用 SQLite 的強(qiáng)大功能的同時(shí),能夠流暢地訪問(wèn)數(shù)據(jù)庫(kù),這篇文章主要為大家介紹了Room組件的具體使用,需要的可以參考下
    2023-08-08

最新評(píng)論

衡阳市| 西乡县| 年辖:市辖区| 万山特区| 青州市| 泽州县| 临沂市| 双柏县| 东乌珠穆沁旗| 景谷| 连云港市| 天全县| 中西区| 呼伦贝尔市| 庆城县| 乌鲁木齐县| 双鸭山市| 长子县| 阿荣旗| 长岭县| 仁化县| 昆明市| 万山特区| 三台县| 惠州市| 峨眉山市| 海晏县| 基隆市| 曲松县| 通海县| 浦县| 长岛县| 海盐县| 洪洞县| 道真| 九台市| 太谷县| 波密县| 潮州市| 靖安县| 奎屯市|