prefrences屏幕添加到活动用定制的窗口标题 [英] Add Prefrences Screen to an Activity with a customized window title
问题描述
我知道它可以将一个按钮添加到prefernces Screeen activtiy。我读了这个问题
如何将按钮添加到preferenceScreen
和它的作品完美。
但是,如果我想补充我的自定义标题我的应用程序只是崩溃。
该customtitle完美的作品在自己的活动和preference屏,按键作品也完全在自己的活动。所以,我的问题,只是基于使这两个功能在一起。
I know its possible to add a button to a prefernces Screeen activtiy. I read this question How to add a button to PreferenceScreen and it works perfect. But if I want to add my custom title my application just crashes. The customtitle works perfect in its own activity and the preference screen with button works also perfect in its own activity. So my problem is only based on bringing these two functions together.
我的继承人code在java文件中的
heres my code in of the java file
public class TestHeadlineActivity extends PreferenceActivity implements OnClickListener{
/** Called when the activity is first created. */
Button settingsButton;
TextView tv_WindowTitleAccuracy;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
addPreferencesFromResource(R.xml.prefs);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
settingsButton = (Button) findViewById(R.id.Button_Settings);
settingsButton.setText("BUTTONTEXT");
settingsButton.setOnClickListener(this);
tv_WindowTitleAccuracy = (TextView) findViewById(R.id.tv_WindowTitleAccuracy);
tv_WindowTitleAccuracy.setText("TEXT");
}
@Override
public void onClick(View v) {
finish();
}
}
这是我的主要XML
<?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"
android:orientation="vertical">
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="10"/>
<Button android:text="This is a button on top of all preferences."
android:layout_height="wrap_content"
android:layout_weight="1" android:layout_width="fill_parent"/>
</LinearLayout>
和我的继承人preFS
and heres my prefs
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<EditTextPreference
android:title="EditText"
android:key="name"
android:summary="Enter your name"
></EditTextPreference>
<CheckBoxPreference
android:title="Music"
android:defaultValue="true"
android:key="checkbox"
android:summary="for the splash screen"
/>
</PreferenceScreen>
谢谢你们
推荐答案
仍然没有答案?可能ü解决它已经但也许别人会发现一些这个链接有用:
still no answer?! probably u solved it already but maybe somebody else will find some of this links useful:
- 自定义标题(解决)
- 装潢preference条屏
- 如何改变preference 背景颜色LI>
- Custom title on preference screen (solved)
- decorating preference screen article
- How to change background color of preference
欢呼声
这篇关于prefrences屏幕添加到活动用定制的窗口标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!