API Demos 2.2 연구 노트 (5) - Window Feature
안 드 로 이 드 는 사전에 고객 화 될 수 있 는 특징 에 상수 로 정의 되 었 다.
int
DEFAULT_FEATURES
The default features enabled
int
FEATURE_CONTEXT_MENU
Flag for the context menu.
int
FEATURE_CUSTOM_TITLE
Flag for custom title.
int
FEATURE_INDETERMINATE_PROGRESS
Flag for indeterminate progress
int
FEATURE_LEFT_ICON
Flag for having an icon on the left side of the title bar
int
FEATURE_NO_TITLE
Flag for the "no title" feature, turning off the title at the top of the screen.
int
FEATURE_OPTIONS_PANEL
Flag for the "options panel" feature.
int
FEATURE_PROGRESS
Flag for the progress indicator feature
int
FEATURE_RIGHT_ICON
Flag for having an icon on the right side of the title bar
다음은 API 데모 에서 Custom Title 을 예 로 들 어 설명 한다.
1. 먼저 클 라 이언 트 화 된 title 을 만 듭 니 다.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/screen"
    android:layout_width="match_parent" android:layout_height="match_parent"
    android:orientation="vertical">
    <TextView android:id="@+id/left_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:text="@string/custom_title_left" />
    <TextView android:id="@+id/right_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:text="@string/custom_title_right" />
</RelativeLayout>
  2. Custom Title. java 에서 클 라 이언 트 화 된 title 을 activity 에 적용 합 니 다.
package com.example.android.apis.app;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.example.android.apis.R;
public class CustomTitle extends Activity {
    @Override
	protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.custom_title);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_1);
        
        final TextView leftText = (TextView) findViewById(R.id.left_text);
        final TextView rightText = (TextView) findViewById(R.id.right_text);
        final EditText leftTextEdit = (EditText) findViewById(R.id.left_text_edit);
        final EditText rightTextEdit = (EditText) findViewById(R.id.right_text_edit);
        Button leftButton = (Button) findViewById(R.id.left_text_button);
        Button rightButton = (Button) findViewById(R.id.right_text_button);
        
        leftButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                leftText.setText(leftTextEdit.getText());
            }
        });
        rightButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                rightText.setText(rightTextEdit.getText());
            }
        });
    }
}
  setContentView 에 앞서 request Window Feature (Window. FEATURE CUSTOM TITLE) 를 호출 하여 제목 을 클 라 이언 트 화 할 것 을 신청 합 니 다.그리고 getWindow (). setFeatureInt 를 호출 하여 새 title 을 activity 에 적용 합 니 다.
클 라 이언 트 화 window feature 시 주의해 야 할 사항:
1. set ContentView 전에 request Feature 를 호출 해 야 합 니 다.request Window Feature = getWindow (). request Feature 이기 때문에 request Window Feature 를 호출 해도 됩 니 다.
2. 기타 title 관련 feature 와 FEATURE 를CUSTOM_TITLE 와 함께 사용 합 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Kotlin의 기초 - 2부지난 글에서는 Kotlin이 무엇인지, Kotlin의 특징, Kotlin에서 변수 및 데이터 유형을 선언하는 방법과 같은 Kotlin의 기본 개념에 대해 배웠습니다. 유형 변환은 데이터 변수의 한 유형을 다른 데이터...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.