2014-05-23 3 views
0

나는 자바/이클립스에서 꽤 경험이있다. 그러나 나는 안드로이드 개발에 완전히 익숙하지 않다. 그리고 그것은 지금까지 아주 이상한 짐승으로 입증되었다. 현재 두 개의 이미지 버튼으로 애플리케이션을 만들려고합니다.안드로이드 - 이클립스가 ImageButton 클래스를 찾을 수 없다

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    android:orientation="vertical" > 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:padding="24dp" 
     android:text="@string/now_playing" /> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <ImageButton 
      android:id="@+id/StartButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/start_button" 
      android:contentDescription="@string/start_button" /> 

     <ImageButton 
      android:id="@+id/StopButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@drawable/stop_button" 
      android:contentDescription="@string/stop_button" /> 

    </LinearLayout> 

</LinearLayout> 

이 올바른 것으로 나타나지만 ImageButtons는 그래픽 레이아웃 탭에서 제대로 렌더링하지 않고, "다음 클래스를 찾을 수 없습니다라는 메시지가 : 다음과 같이 내 XML은 가 - ImageButton (android.widget.ImageButton으로 변경, 빌드 경로 수정, XML 편집) ".

온라인을 조금 둘러 본 후에이 질문이 StackOverflow에서 몇 번 나타 났지만 만족스러운 답변을 찾을 수 없었습니다. 가장 일반적인 대답은 프로젝트를 청소하는 것이었지만 이것은 나에게 아무런 성과가 없었습니다. 어떤 제안?

+0

에 한번 청소에 의해

android:text="@drawable/stop_button" 

교체 : 아 내가보고하지 않았다. 때때로 eclipse에서 xml을 크게 변경하면 이상한 문제가 발생합니다. –

답변

0

가끔씩 Eclipse 그래픽 레이아웃 탭이 코드를 작성할 수없는 반면에 코드를 작성할 수없는 경우가 있습니다. setContentView (R.layout.yourxml)를 사용하여 간단한 활동을 실행 해보십시오. 어떤 일이 발생하는지 확인하십시오 :

public class MainActivity extends Activity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.yourlayout); 
    } 
} 

오류가 계속되면 LogCat을 게시하십시오.

편집 : 두 번째하여 ImageButton에

을 프로젝트를 새로 고침/

android:src="@drawable/stop_button" 
+0

오류가 없습니다. 프로젝트가 실행됩니다. 그러나 안드로이드 시뮬레이터에서 나는 포함 된 이미지 대신에 텍스트가없는 두 개의 회색 버튼을 보았습니다. – user2871915

관련 문제