답변
나는 다음 코드를 작성하고 내 문제를 해결했다. 어쩌면 누구에게나 유용 할 수도 있습니다 next = (Button) findViewById (R.id.next); 다음.setOnClickListener (새 OnClickListener를() {
@Override
public void onClick(View v)
{
if(i<movie_list.length-3)
{
movie_list[i].setVisibility(View.GONE);
movie_list[i+3].setVisibility(View.VISIBLE);
i++;
}else{
Toast.makeText(getApplicationContext(), "That is the end of the buttons ", Toast.LENGTH_SHORT).show();
}
}
});
사용 android:visibility="visible"
또는 android:visibility="gone"
또는 android:visibility="invisible"
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="91dp"
android:layout_toLeftOf="@+id/textView1"
android:text="Button"
android:visibility="visible" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button1"
android:layout_alignLeft="@+id/textView1"
android:text="Button"
android:visibility="invisible" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button2"
android:layout_alignBottom="@+id/button2"
android:layout_toRightOf="@+id/button2"
android:text="Button"
android:visibility="invisible" />
설정 버튼의 가시성에 GONE (버튼을 완전히 "제거"할 것이다 - 버튼 공간이 다른 위젯 사용할 수 있습니다) 또는 INVISIBLE (버튼의 뜻은 "투명되었다 "- 그 공간) 다른 위젯을 사용할 수 없습니다 :
View b = findViewById(R.id.button);
b.setVisibility(View.GONE);
또는 XML에 :
,451,515,<Button ... android:visibility="gone"/>
참고 문헌으로는 : LINK
나는이 코드를했다. next = (Button) findViewById (R.id.next); \t \t next.setOnClickListener (new OnClickListener() {\t \t \t \t \t \t @Override \t \t \t 공개 무효 온 클릭 (뷰 V) \t \t \t { \t \t \t \t 경우 (전 movie_list.length를 <) \t \t \t \t { \t \t \t \t \t movie_list [i] .set 가시성 (View.GONE); \t \t \t \t movie_list [i + 3] .setVisibility (View.VISIBLE); \t \t \t \ti ++; \t \t \t \t한다} else {가 \t \t \t \t \t Toast.makeText (getApplicationContext는() "즉 버튼의 끝"Toast.LENGTH_SHORT) .show(); \t \t \t \t \t} \t \t \t \t }}); 하지만 마지막 버튼을 표시 한 후 다음 버튼을 클릭하면 "앱이 중지되었습니다"오류가 발생합니다. – Vaseph
오케이 내가 실수를 바로 잡았습니다. – Vaseph
네 스스로 해결할 수있는 좋은 .. :) – AndyBoy
하자 당신이 개 버튼이 말 : XML이 쓰기 : 당신이 button1을 클릭 할 때 : 당신의 한 OnCreate 방법에서
<Button android:id="@+id/btn1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 1"/>
<Button android:id="@+id/btn2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="button 2"
android:layout_below="@+id/btn1"
android:visibility="invisible"/>
이 쓰기 아래와 같이 버튼이 보이지 않는 확인 , button2가 나타납니다.
Button btn1 = (Button)findViewById(R.id.btn1);
final Button btn2 = (Button)findViewById(R.id.btn2);
btn1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
btn2.setVisibility(View.VISIBLE);
}
});
는
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="91dp"
android:layout_toLeftOf="@+id/textView1"
android:text="Button"
android:visibility="gone" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button1"
android:layout_alignLeft="@+id/textView1"
android:text="Button"
android:visibility="gone" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button2"
android:layout_alignBottom="@+id/button2"
android:layout_toRightOf="@+id/button2"
android:text="Button"
android:visibility="gone" />
- 먼저 모든 버튼을 갖는 위의 XML 레이아웃을 만들고 버튼이 때문에 초기에 사용하면 공간과 시간을 절약 기본적으로 레이아웃에서 공간을 차지하지 않기 때문에 GONE로 설정합니다.
이제 클릭 이벤트에 대한 코드에서이 버튼의 가시성을 VISIBLE으로 설정하면됩니다.
가시성을 변경하는 단계 HashMap map = new HashMap(); map.put (R.id.button1, new Integer [] {R.id.button2, R.id.button3, R.id.button4});
공개 무효 온 클릭 (뷰 V) {
정수 [] = buttonsToShow map.get (R.id.v.getId());
경우 (buttonsToShow = NULL!) (INT 버튼 : buttonsToShow) 용 {findViewById를 (버튼) .setVisibility (View.VISIBLE);
} }
- 1. 보기 버튼
- 2. 부분은
- 3. 부분은
- 4. 보기 위에 안드로이드 부동 버튼
- 5. 푸시 알림 -보기 버튼 동작
- 6. 보기 컨트롤러에 뒤로 버튼 추가하기
- 7. 자바의 버튼 /보기 컨트롤러를 수정하려고합니다.
- 8. 보기,보기
- 9. MYSQL 업데이트 부분은 그 부분은 문자열 아니고,
- 10. 반환 부분은
- 11. 제거 부분은
- 12. 특정 부분은
- 13. 복사 부분은
- 14. 선택 부분은
- 15. 이해 부분은
- 16. 쓰기 부분은
- 17. 소수 부분은
- 18. Apple 푸시 알림 -보기 버튼 동작
- 19. Magento 관리 주문 버튼 (보기 주문시)
- 20. 보기 페이지 버튼 소스 웹 페이지 클릭
- 21. 보기 외부를 누를 때 삭제 버튼 숨기기
- 22. 그러나 C# IF 부분은 항상 작동합니다. ELSE 부분은 항상 실행됩니다.
- 23. NSRegularExpression, 문자열의 선택 부분은
- 24. 나침반 부분은 언제 사용합니까?
- 25. 모델 내부 부분은 3.2
- 26. PHP 사진 부분은
- 27. 랩 특정 부분은
- 28. 이 XSLT 부분은 무엇을합니까?
- 29. 그렇지 않은 부분은
- 30. HAML의 파셜 부분은
무엇'예 중 먼저 세에 대한 clicking' – Nambi
에 의해 다음 버튼 쇼 다음 세 개의 버튼을 클릭 한 후 부분으로 그들에게 일부를 보여주는 것입니다. – Vaseph
사용, VISIBLE 보이지 GONE 기능 – NagarjunaReddy