Open Iris73851 opened 7 years ago
Bundle bundle =this.getIntent().getExtras(); name = bundle.getString("AlbumName");
//讀取手機解析度
mPhone = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(mPhone);
//mImg = (ImageView) findViewById(R.id.img);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(name);
setSupportActionBar(toolbar);
gridView = (GridView) findViewById(R.id.gridView1);
introduction = (TextView) findViewById(R.id.textView5);
ContentResolver cr = getContentResolver();
String[] projection = { MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA };
//查詢SD卡的圖片
Cursor cursor = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
projection, null, null, null);
thumbs = new ArrayList<String>();
imagePaths = new ArrayList<String>();
String filePath = Environment.getExternalStorageDirectory().toString () +"/Travel/"+name;//抓路徑
// 得到该路径文件夹下所有的文件
File fileAll = new File(filePath);
File[] files = fileAll.listFiles();
count = files.length;
// 将所有的文件存入ArrayList中,并过滤所有图片格式的文件
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (checkIsImageFile(file.getPath())) {
thumbs.add(file.getName());
imagePaths.add(file.getPath());
}else{
try{
//取得SD卡儲存路徑
File mSDFile = Environment.getExternalStorageDirectory();
//讀取文件檔路徑
FileReader mFileReader = new FileReader(file.getPath());
BufferedReader mBufferedReader = new BufferedReader(mFileReader);
String mReadText = "";
String mTextLine = mBufferedReader.readLine();
//一行一行取出文字字串裝入String裡,直到沒有下一行文字停止跳出
while (mTextLine!=null)
{
mReadText += mTextLine+"\n";
mTextLine = mBufferedReader.readLine();
}
//文字放入mText裡,並清空mEdit
introduction.setText(mReadText);
} catch (Exception e){
e.printStackTrace();
}
}
}
已完成,解析度太大問題