DNPereira Posted December 3, 2012 Report Share Posted December 3, 2012 Pessoal, o problema e o seguinte. Não estou a conseguir ir buscar o imagem ao sdcard. public class LayoutOneGridView extends BaseAdapter { private Context mContext; public LayoutOneGridView(Context c) { mContext = c; } public int getCount() { return LayoutOne.themeInfo.size(); } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView=new ImageView(mContext); try { AssetManager assetmanager = mContext.getAssets(); LayoutInflater inflater = LayoutInflater.from(mContext); convertView = inflater.inflate(R.layout.buttontext, null); BufferedInputStream themeButtonBuf = new BufferedInputStream(assetmanager.open(LayoutOne.themeInfo.get(position)+"/themeButton.png")); Bitmap themeButton = BitmapFactory.decodeStream(themeButtonBuf); imageView = (ImageView)convertView.findViewById(R.id.themeButton); imageView.setImageBitmap(themeButton); BufferedInputStream themeButtonTextBuf = new BufferedInputStream(assetmanager.open(LayoutOne.themeInfo.get(position)+"/themeButtonText.png")); Bitmap themeButtonText = BitmapFactory.decodeStream(themeButtonTextBuf); imageView = (ImageView)convertView.findViewById(R.id.themeButtonText); imageView.setImageBitmap(themeButtonText); BufferedInputStream themePreviewBuf = new BufferedInputStream(assetmanager.open(Layout One.themeInfo.get(position)+"/previewTag.png")); Bitmap themePreview = BitmapFactory.decodeStream(themePreviewBuf); imageView = (ImageView)convertView.findViewById(R.id.themePreview); imageView.setImageBitmap(themePreview); FileInputStream themeSdcardBuf = new FileInputStream(Environment.getExternalStorageDirectory()+java.io.File.separator+LayoutOne.themeInfo.get(position)+"/themeButton.png"); Bitmap themeSdcard = BitmapFactory.decodeStream(themeSdcardBuf); imageView = (ImageView)convertView.findViewById(R.id.sdCardImage); imageView.setImageBitmap(themeSdcard); themeSdcardBuf.read(); themeButtonTextBuf.close(); themeButtonBuf.close(); themePreviewBuf.close(); themeSdcardBuf.close(); } catch (IOException e) { e.printStackTrace(); } return convertView; } } quando troco o arralist pelo nome da pasta, ele coloca lá a imagem. obrigado Link to comment Share on other sites More sharing options...
DNPereira Posted December 3, 2012 Author Report Share Posted December 3, 2012 done Link to comment Share on other sites More sharing options...
NunoDinis Posted December 3, 2012 Report Share Posted December 3, 2012 Posta o código. Pode vir a ser útil para alguém. Estranha forma de vida que tem a capacidade de transformar comandos em mensagens de erro. ndsotware.org Link to comment Share on other sites More sharing options...
DNPereira Posted December 3, 2012 Author Report Share Posted December 3, 2012 Aqui esta public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView=new ImageView(mContext); try { AssetManager assetmanager = mContext.getAssets(); LayoutInflater inflater = LayoutInflater.from(mContext); convertView = inflater.inflate(R.layout.buttontext, null); BufferedInputStream themeButtonBuf = new BufferedInputStream(assetmanager.open(LayoutOne.themeInfo.get(position)+"/themeButton.png")); Bitmap themeButton = BitmapFactory.decodeStream(themeButtonBuf); imageView = (ImageView)convertView.findViewById(R.id.themeButton); imageView.setImageBitmap(themeButton); BufferedInputStream themeButtonTextBuf = new BufferedInputStream(assetmanager.open(LayoutOne.themeInfo.get(position)+"/themeButtonText.png")); Bitmap themeButtonText = BitmapFactory.decodeStream(themeButtonTextBuf); imageView = (ImageView)convertView.findViewById(R.id.themeButtonText); imageView.setImageBitmap(themeButtonText); BufferedInputStream themePreviewBuf = new BufferedInputStream(assetmanager.open(LayoutOne.them eInfo.get(position)+"/previewTag.png")); Bitmap themePreview = BitmapFactory.decodeStream(themePreviewBuf); imageView = (ImageView)convertView.findViewById(R.id.themePreview); imageView.setImageBitmap(themePreview); FileInputStream themeSdcardBuf = new FileInputStream(Environment.getExternalStorageDirectory()+java.io.File.separator+LayoutOne.themeInfo.get(position)+"/themeButton.png"); Bitmap themeSdcard = BitmapFactory.decodeStream(themeSdcardBuf); imageView = (ImageView)convertView.findViewById(R.id.sdCardImage); imageView.setImageBitmap(themeSdcard); themeSdcardBuf.read(); themeButtonTextBuf.close(); themeButtonBuf.close(); themePreviewBuf.close(); themeSdcardBuf.close(); } catch (IOException e) { e.printStackTrace(); } try { FileInputStream(Environment.getExternalStorageDirectory()+java.io.File.separator+LayoutOne.themeInfo.get(position)+"/themeButton.png"); Bitmap themeSdcard = BitmapFactory.decodeStream(themeSdcardBuf); imageView = (ImageView)convertView.findViewById(R.id.sdCardImage); imageView.setImageBitmap(themeSdcard); } catch (IOException e) { e.printStackTrace(); } return convertView; } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now