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

프래그먼트 질문입니다.

0 추천

프래그먼트에서 다음과 같이 작성을 했는데요 버튼을 클릭을 하여도 숫자가 증가하지 않습니다.

프래그먼트

    @Override
    public void onClick(View v) {
        Log.d("Content_Main","onClick:"+v.getId());
        switch(v.getId()) {
       
        // 시간 -10초
        case R.id.left_btn:
            count-=10;
            mtimebar.setText(""+count);
            break;

        // 시간 +10초
        case R.id.right_btn:
            count+=10;
            mtimebar.setText(""+count);

            break;

        // Hz -1
        case R.id.hz_left:
            count--;
            mhztext.setText(""+count);
            message = "down";
            if(message != null && message.length() > 0)
                sendMessage(message);
            break;

        // Hz +1
        case R.id.hz_right:
            count++;
            mhztext.setText(""+count);
            message = "up";
            if(message != null && message.length() > 0)
                sendMessage(message);
            break;
        default:
            break;
        }

    }

레이아웃

 <!-- Hz -->
    <TextView
        android:id="@+id/hztext"
        android:layout_width="40dp"
        android:layout_height="44dp"
        android:layout_marginLeft="70dp"
        android:layout_marginStart="70dp"
        android:gravity="center"
        android:text="0"
        android:textColor="#ffffff"
        android:textSize="35sp"
        app:layout_constraintBottom_toBottomOf="@+id/imageView"
        app:layout_constraintStart_toStartOf="@+id/imageView"
        app:layout_constraintTop_toTopOf="@+id/imageView" />

    <!-- Hz down 버튼 -->
    <Button
        android:id="@+id/hz_left"
        android:layout_width="20dp"
        android:layout_height="30dp"
        android:layout_marginLeft="50dp"
        android:layout_marginStart="50dp"
        android:layout_weight="1"
        android:background="@drawable/arrow_left_black"
        app:layout_constraintBottom_toBottomOf="@+id/imageView"
        app:layout_constraintStart_toStartOf="@+id/imageView"
        app:layout_constraintTop_toTopOf="@+id/imageView" />

    <!-- Hz up 버튼 -->
    <Button
        android:id="@+id/hz_right"
        android:layout_width="20dp"
        android:layout_height="30dp"
        android:layout_marginLeft="110dp"
        android:layout_marginStart="110dp"
        android:layout_weight="1"
        android:background="@drawable/arrow_right_black"
        app:layout_constraintBottom_toBottomOf="@+id/imageView"
        app:layout_constraintStart_toStartOf="@+id/imageView"
        app:layout_constraintTop_toTopOf="@+id/imageView" />

 

익명사용자 님이 2018년 10월 10일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...