2012-11-05 2 views
0

글쎄, 내 프로그램은 지금까지, compilable 및 모든 머물고, 나는 그것에 소리를 추가하려고, 그래서 "원시"폴더를 만들었고, mp3 파일에 갇혀있다. 그런 다음 사용하려고 시도했는데 어떤 이유로 든 오류가 발생하기 시작했습니다. Ctrl + Z를 눌러 사운드가 추가되기 전에 다시 돌아올 때까지 기다립니다. 프로그램은 여전히 ​​오류가 발생했습니다. 난 원시 폴더를 삭제하고 여전히 오류가 있습니다 [아래 프로그램에 표시] 이건 내 프로그램에서 단 한 클래스이며 다른 것들이 있습니다.내 레이아웃을 해결할 수없는 이유는 무엇입니까? (안드로이드/자바)

package scouting.form; 

import android.R;//Don't use android.R here; use a fully qualified name for each usage instead - this one only comes up *sometimes...* 
import android.os.Bundle; 
import android.app.Activity; 
import android.content.Intent; 
import android.view.Menu; 
import android.view.View; 
import android.widget.Button; 
import android.widget.EditText; 

public class Login extends Activity { 

    Button login; 
    EditText user; 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_login);//Error: activity_login cannot be resolved or is not a field 
     login=(Button) findViewById(R.id.button1);//NO ERROR even though the next line has an error... 
     user=(EditText) findViewById(R.id.editText1);//Error: editText1 cannot be resolved or is not a field 
     login.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) { 
       Intent openScouting = new Intent("com.cody.graham.SCOUTING"); 
       startActivity(openScouting); 
      } 
     }); 
    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     getMenuInflater().inflate(R.menu.activity_login, menu);//Error: activity_login cannot be resolved or is not a field 
     return true; 
    } 
} 

나는 그들이 거기에, 나는 레이아웃을 열고 여전히에있는 레이아웃 "activity_login"의 텍스트 편집 상자가 있음을 확인할 수 있습니다 전체 시간이었다, 레이아웃 및 메뉴가 여전히 있다는 것을 알고 레이아웃 폴더 및 편집 텍스트 상자에는 줄이 있습니다.

이 있습니다.

답변

3

맨위로 보시겠습니까?

import android.R;//Don't use android.R here; use a fully qualified name for each usage instead - this one only comes up *sometimes... 

당신은 아마도 그 의견이 말하는 것을주의해야합니다. ;) android.R에 대한 가져 오기를 제거하면 프로젝트의 R 파일이 대신 사용됩니다 (activity_login 인 경우).

+1

나는 무엇을 말할 지 모르겠다. 나는 그것을 한순간에 제거했다. 나는 그것이 내가 필요로하는 수입이 없다고 불평했다. 그래서 나는 그것을 다시 첨가했다. 내가 그것을 제거했을 때 이번에는 ... (페이스 팔먼?) 어쨌든, 감사합니다 !! – bluebl1

+0

@ bluebl1 여러분을 환영합니다! 왼쪽에있는 체크 표시를 선택하여 정답으로 표시하는 것을 잊지 마십시오. ;) – Eric

+0

내가 다시 말하고있는 문제가 있습니다. 나는 지금 "import.android.R"을 가지고 있지 않지만 다음 줄을 가지고있다. 'clr = (Button) findViewById (R.id.CLREntries);' "CLREntries"를 해결할 수 없다는 메시지가 나타납니다. 이 페이지의 레이아웃에서이 라인의 버튼이 있습니다 : 'android : id = "@ + id/CLREntries"' 그리고 오류가 없습니다 버튼으로. – bluebl1

0

잘못된 R.java을 가져오고 있습니다. Eclipse (gen 폴더에 있음)에서 생성 된 것을 가져와야합니다. control-shift-o을 입력하여 자동으로 가져올 수 있습니다. 자산을 추가 할 때 때로는 필요하지 않은 Project> Clean을 실행해야 할 수도 있습니다.

원시 폴더는 res/ 디렉토리 아래에 있어야합니다.

관련 문제