編輯:關於Android編程
list為Assets下目錄名
//本地讀取 private ArrayListgetImageFromAssetsFile(String list) { String test=list; ArrayList newpiclistinfo = new ArrayList (); String[] list_image = null; try { //得到assets/list/目錄下的所有文件的文件名,以便後面打開操作時使用 list_image = this.getAssets().list(list); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } for(int i=0;i PicListAdapter.java
package com.cartoon.adapters; import java.util.ArrayList; import com.cartoon.R; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.View.MeasureSpec; import android.view.ViewGroup; import android.view.ViewGroup.MarginLayoutParams; import android.view.WindowManager; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.RelativeLayout; import android.widget.TextView; public class PicListAdapter extends ArrayAdapter{ public PicListAdapter(Context context, int textViewResourceId, ArrayList objects) { super(context, textViewResourceId, objects); } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder =null; View view; WindowManager wm = (WindowManager) getContext() .getSystemService(Context.WINDOW_SERVICE); int width = wm.getDefaultDisplay().getWidth(); int height = wm.getDefaultDisplay().getHeight(); if (convertView == null) { view = LayoutInflater.from(getContext()).inflate(R.layout.piclist_item, null); holder = new ViewHolder(); holder.piclist_item = (ImageView)view.findViewById(R.id.piclist_item); //設置圖片的位置 ViewGroup.LayoutParams margin = new ViewGroup.LayoutParams( holder.piclist_item.getLayoutParams()); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(margin); layoutParams.height = (int) (width*0.5677);//設置圖片的高度 layoutParams.width = width; //設置圖片的寬度 layoutParams.setMargins(15, 0, 15, 0); holder.piclist_item.setLayoutParams(layoutParams); holder.piclist_item.setScaleType(ImageView.ScaleType.FIT_START); view.setTag(holder); } else { view = convertView; holder = (ViewHolder)convertView.getTag(); } final PicListInfo singleoder = getItem(position); if (singleoder != null) { holder.piclist_item.setImageBitmap(singleoder.getPicUrl()); } return view; } public class ViewHolder{ public ImageView piclist_item; } }
PicListInfo.java
package com.cartoon.adapters; import android.graphics.Bitmap; public class PicListInfo { private Bitmap PicUrl; //圖片地址 //下面是上面屬性的get和set方法 public Bitmap getPicUrl() { return PicUrl; } public void setPicUrl(Bitmap picUrl) { PicUrl = picUrl; } }
美顏包含磨皮、美白、瘦臉等效果,其中磨皮算法在很多博客中均有介紹例如:雙指數邊緣平滑濾波器用於磨皮算法的嘗試選擇性模糊及其算法的實現基於局部均方差相關信息的圖像去噪及其在
本文介紹九宮格程序的設計代碼。一.相關介紹(一)效果顯示1.程序剛運行時的效果:2.在頁面上點擊選擇並滑動時的畫面3.選擇密碼之後的顯示(二)功能介紹1.點擊某圓圈後,在
引言Service服務是Android四大組件之一,在Android中有著舉足重輕的作用。Service服務是工作的UI線程中,當你的應用需要下載一個文件或者播放音樂等長
我們來定制一下吧布局文件:activity_main.xml <framelayout android:layout_height=0dp android:l