마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

xml에서 View를 상속받은 내부클래스를 추가하고싶어요

0 추천

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

   

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="도" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="개" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="걸" />

    <Button
        android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="윷" />

    <Button
        android:id="@+id/button5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="모" />
   
    <view
        class="com.example.koreanboardgame.MainActivity$MyView"
        android:id="@+id/MyView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        />

</LinearLayout>

 

이게 xml 전문이구요

보시다시피 view를 추가했어요

MyView는 MainAcitivity.java에 있는 내부클래스구요

내부클래스를 쓰고 싶을 땐 $를 쓴다고 배웠는데

왜그런지는 모르겠는데 자꾸 에러가 나네요 ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ

binary line 어쩌구 하는 에러는 class 가 없어서 뜨는 에러라는데..

도움을 부탁드립니다

익명사용자 님이 2013년 8월 4일 질문

1개의 답변

0 추천

<view class 가 아니고

<com.example.koreanboardgame.MainActivity$MyView  겠죠

그런데 inner class 면 static 이 아니면 문제가 될 수 있겠네요

aucd29 (218,390 포인트) 님이 2013년 8월 5일 답변
...