0
我需要保存scrollview及其所有內容,然後通過電子郵件發送。主要問題是保存整個滾動視圖,而不是屏幕上顯示的內容。有沒有辦法保存整個滾動視圖,如果有的話如何?如何在android上保存併發送一個完整的scrollview?
它在scrollView中的LinearLayout中。 我試圖保存表,這裏是我使用的保存表的方法:
public void saveTable(){
View v = findViewById(R.id.all_tables);
v.setDrawingCacheEnabled(true);
TextView title = (TextView)findViewById(R.id.title);
int height = ((ScrollView) v).getChildAt(0).getHeight();
int width =((ScrollView) v).getChildAt(0).getWidth();
v.layout(0, title.getMeasuredHeight(), width, height);
v.buildDrawingCache();
bm = Bitmap.createBitmap(v.getDrawingCache());
try {
file = new File(Environment.getExternalStorageDirectory() + "/CE_Budgets");
if (!file.exists())
file.mkdir();
file = new File(Environment.getExternalStorageDirectory() + "/CE_Budgets/tables.png");
if (!(file.exists())) {
try {
file.createNewFile();
} catch (IOException e) {
Toast.makeText(getApplicationContext(), "It didn't work", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
FileOutputStream out = new FileOutputStream(file.getPath());
bm.compress(CompressFormat.PNG, 100, out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
解釋你正在保存的內容併發布一些代碼 – tyczj
是的,請解釋你想要什麼......以及以什麼格式? (文本,圖片,..)可以提取你的列表視圖內容並設置結果的格式,但這是你想要的嗎? – azerto00