2013-07-20 1 views
2

해결, 나는 스크린 샷을 취할 코드가 될 수 없습니다 :이 LayoutRoot는 내가 안드로이드 자바 프로그래밍 초보자 해요

"layoutroot cannot be resolved or is not a field"

I 돈 : 그것은 오류를 제공

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"를 정의해야하는지 알지 못한다. 누구든지이 문제를 해결할 수 있습니까? 고맙습니다!

답변

0

확인, 당신이 오기 다음 제거보다android.R

을 가져온 경우

import android.R; 

그것은해야한다 :

import your.application.packagename.R; 

편집

당신이 때 당신은 또한, 오타가layoutroot

+0

가져 오기가 없습니다. 하지만 layoutroot는 어디에도 정의되어 있지 않습니다. 버튼과리스트 뷰가 있지만 layoutroot는 없습니다. 그것을 정의해야합니까? –

+0

아직 해결하지 못했습니다. –

+1

예, 분명히 선언해야합니다! –

1

정의해야합니다 : 당신은 't'를 누락

View content = findViewById(R.id.layouroot); 

을, 그것이 있어야 :

View content = findViewById(R.id.layoutroot); 
+0

나는 이미 누락 된 "t"를 추가했지만 여전히 동일한 오류를 제공합니다 –

관련 문제