버튼 가시성에 문제가 있습니다. 나는 제목 표시 줄에서 2 버튼을 가지고 있습니다. 그들 중 하나가 편집 중 하나가 완료되었습니다. 먼저 편집 버튼을 클릭하고 편집 버튼을 클릭하면 버튼 가시성이 false가되고 버튼 가시성이 완료됩니다.제목 표시 줄의 가시성 단추를 프로그래밍 방식으로 변경 하시겠습니까?
나는 그들의 ID를 xml에서 얻었고, 그 중 하나를 클릭하면 나는 가시성을 바꾸고 싶지만 edit.setVisibility(); 작동하지 않습니다. 무엇이 잘못 되었나요? 편집 버튼이 보입니다. 프로그램 가시성을 변경하고 싶습니다.
아무도 모를 수 있습니까?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final boolean customTitle = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
edit=(Button)findViewById(R.id.edit);
done=(Button)findViewById(R.id.done);
edit.setVisibility(View.INVISIBLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.main);
if (customTitle) {
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.main);
}
main.xml에 : 당신의 LinearLayout의 방향 매개 변수 :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:id="@+id/edit"
android:layout_width="57px"
android:layout_height="wrap_content"
android:text="edit"/>
<Button android:id="@+id/done"
android:layout_width="57px"
android:layout_height="wrap_content"
android:text="done"/>
</LinearLayout>
이런 종류의 동작을 수행하려면 작업 표시 줄을 사용하십시오. 액션 바는 Android 3.0 이상에서 기본으로 제공되며 이전 버전의 Android (예 : ActionBarSherlock)에서 액션 바를 제공하기위한 다양한 라이브러리가 있습니다. – CommonsWare