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PzuIP04/VTo/PyY/JGckPz8/MzdSRnY/dj8/PyhGP0k/PzomP016Pz8/PysJWy8/Mj84HF14P0VZOTtFP0U/P2Q/TT91dD8/Xz8fP08/Pz8/Yz9PP3U/Q1Q/Pz8/P2g/Pww/Pyw/CEt8Pz8/P1c/JT8IPz8/Hz8ABj8/ET9+Mj8AP0M/Z0lkPz95P15qPz8/Xz8/P1I/Pw8/Oj91ID8bPz1HPz8/Pz9/P30/DTw/WT8/bwJoWns/fj99bXs/JGE/Nj9WLGFpCAoLPD8/ADc7ET8/Pz8aPz8/CT8/PgpaeB8/Pz8/ZRw/Pz8/Pz8/Pyo/P04/AFw/UAABVVVVQAAKP2w+Bws6FD8/Oj82P0s/Pz8APz8aPz9ybEZdPz8aPz9CPz8/bD8/Nj97dz9tfmhfBT8gPz8APz9RPz8QP2Y/DjQ/Hl9qPz8/dT8/Pz8/Pz8/HT94TT8/Pzo/U2w/P2Y/QSIWPz8kPz8/Pw9fPz0/Pz8/Pws/FhFbWT8nPx4aPz8GPz89Pz9PNE0qWj8uPz8NPz9zeD8pFD8/Pzc/Pz8TPwtNWj9LPz9LPzUbP1g/Pz8IdQc/UT9uP1E/ES4/aj9lSj8QPD8/ED8VPw0/AGB/BXgnPwU/PwA/Pz8/Pz9YGT8JLmU/PxY/RysxP3kKGT8tPD8/PzcEPz8/Zj8/Hz8VPz8Lbz8ePT8ealE/DT9pej0/Nj8lP2g/FisuPwwWP0IAEC8/PyQ/PzJeMT9UPz9dPz9fP08/Xz9NPz94Q00/Tz9NPj9LKj8PJz89Pz8yQj8nP1N3KD9yPzY/ZiM0UAc/";
byte[] b = s.getBytes();
Bitmap bmp = BitmapFactory.decodeByteArray(b, 0, b.length);
而下面的設置gridview的內容:
imageView.setImageBitmap(bmp);
卜所有我得到的是我的GridView中的空白點!我不知道有什麼問題?!
你是不是你的base64轉換爲字節。事實上,你只是將base64的字符串轉換爲字節 – waqaslam 2012-02-22 09:28:08