我是android java编程的新手,我有一个截图代码:
View content = findViewById(R.id.layoutroot); //it gives the "layoutroot cannot be resolved or is not a field" error
content.setDrawingCacheEnabled(true);
Bitmap bitmap = content.getDrawingCache();
File file = new File(Environment.getExternalStorageDirectory() + "/test.png");
try
{
file.createNewFile();
FileOutputStream ostream = new FileOutputStream(file);
bitmap.compress(CompressFormat.PNG, 100, ostream);
ostream.close();
}
catch (Exception e)
{
e.printStackTrace();
}
它给出了错误:
“layoutroot 无法解析或不是字段”
我不知道我是否必须定义“layoutroot”,只是不知道!谁能帮我解决这个问题?谢谢你!