Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android应用程序中的自定义标题错误_Android_Custom Titlebar - Fatal编程技术网

android应用程序中的自定义标题错误

android应用程序中的自定义标题错误,android,custom-titlebar,Android,Custom Titlebar,我为我的简单hello world应用程序使用自定义标题。 我在eclipse中的AVD emulator中运行了它,它可以正常工作,但当我在youwave enulator或真实设备中运行此apk文件时,它在启动应用程序之前停止了,并显示错误消息“不幸的是,测试已停止”。 我的活动代码、布局和清单在这里。谁能帮我一下吗 package com.example.test; import android.os.Bundle; import android.app.Activity; import

我为我的简单hello world应用程序使用自定义标题。 我在eclipse中的AVD emulator中运行了它,它可以正常工作,但当我在youwave enulator或真实设备中运行此apk文件时,它在启动应用程序之前停止了,并显示错误消息“不幸的是,测试已停止”。 我的活动代码、布局和清单在这里。谁能帮我一下吗

package com.example.test;

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

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
          requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
          setContentView(R.layout.activity_main);
          getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}
我的title.xml是:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/txv_title"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:drawableLeft="@drawable/ic_launcher"
    android:gravity="right"
    android:text="@string/app_name"
    android:textAppearance="?android:attr/textAppearance" />

my manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.test"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.test.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

</RelativeLayout>


您能发布您的错误吗?在发布问题之前使用搜索,可能的重复应用程序无法在实际设备中启动,并且出现此错误“不幸的是,测试已停止”