0

私は* FEATURE_CUSTOM_TITLEを他のタイトル機能と組み合わせることができない*というエラーメッセージを表示する次のコードを持っています(私は知りません...)

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

String customTitleStr = getIntent().getExtras().getString("Title");

Boolean customTitleSupported = this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

if ( (customTitleSupported) && (customTitleStr != null) ) {
  getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.override_titlebar);
  final TextView myTitleText = (TextView) findViewById(R.id.myTitleText);
  if ( myTitleText != null ) {
      myTitleText.setText(customTitleStr);
  }                  
}

setContentView(R.layout.);を配置してみました。this.requestWindowFeatureの前後の両方ですが、変更はありません。

私のマニフェストはこれを対象としています:

<uses-sdk
    android:minSdkVersion="8"                
    android:targetSdkVersion="17" 
  />

参考までに(関連があるかどうかはわかりません)、タイトルバーのテーマ設定にも問題があります。(単に無視されます。)

関連する場合に備えて、私のテーマのコードスニペット:

AndroidManifest.xml:

  <application
    android:allowBackup="true"
    android:icon="@drawable/replace__logo__app_android"
    android:label="@string/MicAppName"
    android:theme="@style/MicTheme"
    android:name="com.examples.example.MicApp"    
  >

スタイル.xml:

   <style name="AppBaseTheme" parent="android:Theme.Light">
   </style>

   <style name="AppTheme" parent="AppBaseTheme">
   </style>

   // ...

   <style name="MicTheme" parent="AppTheme">
     <item name="android:windowTitleSize">44dip</item>
     <item name="android:windowTitleBackgroundStyle">@style/MicWindowTitleBackground</item>
     <item name="android:windowTitleStyle">@style/MicWindowTitle</item>     
   </style>
4

1 に答える 1

0

このコードで試してみてください。

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;

public class CustomTitleBar extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
            setContentView(R.layout.main);
            getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.mytitle);

    }
}

カスタム タイトル バーを設定する方法の詳細については、以下のチュートリアルに従ってください。

http://www.edumobile.org/android/android-programming-tutorials/creating-a-custom-title-bar/

http://www.powenko.com/en/?p=214

http://7thursdays.wordpress.com/2012/10/14/how-to-make-a-custom-title-with-android/ これがお役に立てば幸いです。

ここでの編集 は、作業中のスクリーンショットです。

ここに画像の説明を入力

于 2013-06-10T11:31:03.650 に答える