안드로이드 개발 질문/답변
(글 수 45,052)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:orientation="vertical"
android:id="@+id/lastestLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<Button
android:layout_width="fill_parent"
android:layout_height="50px"
android:id="@+id/lastestButton"
android:text="최신 비디오"
/>
<ImageView
android:id="@+id/lastestImageView"
android:layout_below="@+id/lastestButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_1"
/>
</RelativeLayout>
<RelativeLayout
android:layout_below="@+id/lastestButton"
android:orientation="vertical"
android:id="@+id/bestLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<Button
android:layout_width="fill_parent"
android:layout_height="50px"
android:id="@+id/bestButton"
android:text="인기 비디오"
/>
<ImageView
android:id="@+id/bestImageView"
android:layout_below="@+id/bestButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_2"
/>
</RelativeLayout>
</RelativeLayout>
현재 레이아웃은 위와 같습니다.
[최신 비디오 버튼을 누르면 위와 같이 인기비디오 레이아웃이 아래로 이동합니다.]
최신비디오 레이아웃에 인기비디오 레이아웃이 위에 있습니다.
최신비디오버튼을 누르면 인기비디오 레이아웃이 아래로 이동합니다.
인기비디오 버튼만 남기고 Invisible시킵니다.
이제는 인기비디오버튼을 눌러 위로 올라오게 해야 하는데 현재 인기비디오 버튼이 클릭이 안됩니다.
대신 인기비디오버튼이 이동하기 전의 위치인, 두번째 그림에서 하얀색으로 표시한 곳을 클릭하면 화면이동이 됩니다.
레이아웃과 관련이 있는것 같은데....
(자바파일을 첨부합니다. TopDownDisplay2.java )
이유를 잘 모르겠습니다. 조언 부탁드립니다. ^^
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:orientation="vertical"
android:id="@+id/lastestLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<Button
android:layout_width="fill_parent"
android:layout_height="50px"
android:id="@+id/lastestButton"
android:text="최신 비디오"
/>
<ImageView
android:id="@+id/lastestImageView"
android:layout_below="@+id/lastestButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_1"
/>
</RelativeLayout>
<RelativeLayout
android:layout_below="@+id/lastestButton"
android:orientation="vertical"
android:id="@+id/bestLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<Button
android:layout_width="fill_parent"
android:layout_height="50px"
android:id="@+id/bestButton"
android:text="인기 비디오"
/>
<ImageView
android:id="@+id/bestImageView"
android:layout_below="@+id/bestButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_2"
/>
</RelativeLayout>
</RelativeLayout>
현재 레이아웃은 위와 같습니다.

[최신 비디오 버튼을 누르면 위와 같이 인기비디오 레이아웃이 아래로 이동합니다.]
최신비디오 레이아웃에 인기비디오 레이아웃이 위에 있습니다.
최신비디오버튼을 누르면 인기비디오 레이아웃이 아래로 이동합니다.
인기비디오 버튼만 남기고 Invisible시킵니다.
이제는 인기비디오버튼을 눌러 위로 올라오게 해야 하는데 현재 인기비디오 버튼이 클릭이 안됩니다.
대신 인기비디오버튼이 이동하기 전의 위치인, 두번째 그림에서 하얀색으로 표시한 곳을 클릭하면 화면이동이 됩니다.
레이아웃과 관련이 있는것 같은데....
(자바파일을 첨부합니다. TopDownDisplay2.java )
이유를 잘 모르겠습니다. 조언 부탁드립니다. ^^
2009.12.01 14:31:43
정확한 이유는 모르지만 계층뷰어로 확인한번 해보세요, 버튼 위에 레이아웃이 올라간게 아닌지 의심됩니다.
또는, Log를 이용해 온클릭이 안먹는 건지, 먹는데 실행이 안되는 건지 확인하시어 점점 범위를 좁혀가는게 좋을 듯해요
2009.12.01 15:44:14
아마도 레이아웃의 문제가 아닐까 싶은데요...
물론 제 생각일뿐이지만...
비슷하게 레이아웃만 구성해봤는데요.
올려주신 xml 대로 작성하면 화면이 정상적으로 보이지 않는군요.
test는 1.6 sdk 사용했구요.
약간 수정을 해본거시...
두 번째 "인기 비디오" 를 감싸는 레이아웃의 속성을 보면...
android:layout_below="@+id/lastestButton"
이렇게 되어 있는데요.
android:layout_below="@+id/lastestLayout"
으로 바꾸니 일단 첫 화면은 올려주신 그림처럼 나오네요.
실제 동작에 관해서는 코드가 없으니 뭐라고 말씀드리기 어려울듯요;;
뭐 간단한 체크를 해본다면...
if( findViewById(R.id.bestButton) == null )
{
Toast.makeText(this, "인기버튼 없음", Toast.LENGTH_LONG).show();
}
else
{
((Button)findViewById(R.id.bestButton).setOnClickListener( ... );
}
요런 코드를 넣어서 실제 버튼을 지대로 찾아서 리스너 연결이 되는지? 정도 체크해보는거 말곤...
그럼 즐프하세요~
물론 제 생각일뿐이지만...
비슷하게 레이아웃만 구성해봤는데요.
올려주신 xml 대로 작성하면 화면이 정상적으로 보이지 않는군요.
test는 1.6 sdk 사용했구요.
약간 수정을 해본거시...
두 번째 "인기 비디오" 를 감싸는 레이아웃의 속성을 보면...
android:layout_below="@+id/lastestButton"
이렇게 되어 있는데요.
android:layout_below="@+id/lastestLayout"
으로 바꾸니 일단 첫 화면은 올려주신 그림처럼 나오네요.
실제 동작에 관해서는 코드가 없으니 뭐라고 말씀드리기 어려울듯요;;
뭐 간단한 체크를 해본다면...
if( findViewById(R.id.bestButton) == null )
{
Toast.makeText(this, "인기버튼 없음", Toast.LENGTH_LONG).show();
}
else
{
((Button)findViewById(R.id.bestButton).setOnClickListener( ... );
}
요런 코드를 넣어서 실제 버튼을 지대로 찾아서 리스너 연결이 되는지? 정도 체크해보는거 말곤...
그럼 즐프하세요~
2009.12.01 23:26:40
android:layout_below="@+id/lastestButton" -> android:layout_below="@id/lastestButton" +를 빼셔야됩니다. id가 쫑나서 그런듯 -_-;; 밑에 다른 레이아웃들도 전부 +id로 되어있네요 다 빼세요. view의 id를 생성할때는 @+id/... 를 사용해야되지만 이미 존재하는 id를 가리키는 경우에는 @id/... 로 쓰셔야합니다.
2009.12.02 13:22:33
클릭 했을 때 반응이 없는 건지 클릭 자체가 않되는건지 로그를 찍어 보심이 어떨가 합니다.. 이미 등록 되어 있는게 동작 않할리는 없을거 같아요..
그리고 인기비디오 클릭리스너에서 if로 분기되는 부분이 없는거 보면 탑으로 올라가는 부분이 없는거 아닐까요??
그리고 인기비디오 클릭리스너에서 if로 분기되는 부분이 없는거 보면 탑으로 올라가는 부분이 없는거 아닐까요??
2009.12.02 17:31:54
이런 문제가 저 말고 또 있네요. ㅎ
http://groups.google.com/group/android-developers/browse_thread/thread/091c896bd1b8eee8
http://groups.google.com/group/android-developers/browse_thread/thread/091c896bd1b8eee8