10
A
回答
2
我认为这是你正在寻找。
PreferenceScreen screen = createPreferenceHierarchy();
...
this.setContentView(rootView);
=>我想你可以从XML布局设置也。
setPreferenceScreen(screen);
+0
链接已损坏:( – philipp
12
是的,这是可行的。为布局道歉,我粘贴似乎永远保持正确的格式,但内容的作品...
Preferences.java
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.view.View;
import android.widget.Button;
public class Preferences extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.preference_holder);
addPreferencesFromResource(R.layout.preferences);
Button backButton = (Button) findViewById(R.id.backPrefBurron);
backButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(getBaseContext(),
BTFirstTab.class);
startActivity(myIntent);
}
});
}
}
则偏好holder.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">
<LinearLayout android:orientation="horizontal"
android:background="@color/bto_dark_green" android:layout_width="fill_parent"
android:gravity="center_vertical" android:layout_height="wrap_content"
android:paddingTop="4dip">
<Button android:id="@+id/backPrefBurron" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Home" />
<TextView android:id="@+id/backText" android:textSize="14dip"
android:paddingLeft="5dip" android:textColor="@color/white"
android:textStyle="bold" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1.0"
android:text="Preferences: Home will update all areas of the app" />
</LinearLayout>
<ListView android:id="@android:id/list" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
则偏好.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/bto_light_green">
<EditTextPreference android:title="Your BTO UserName"
android:key="username" android:summary="Please provide your username"> </EditTextPreference>
<EditTextPreference android:title="Your BTO Password"
android:password="true" android:key="password" android:summary="Please provide your password (case sensitive)"></EditTextPreference>
<ListPreference android:title="Species order"
android:summary="This preference selects the species order for some viewing sightings activities"
android:key="speciesorder" android:defaultValue="date_order" android:entries="@array/listArray"
android:entryValues="@array/listValues"></ListPreference>
</PreferenceScreen>
这样我就可以在其他页面中使用通用标题。
+0
这是可能的,当我使用preferenceFragment? – Michal
相关问题
- 1. 如何在Android上的PreferenceScreen中使用自定义CheckBox
- 2. Android如何绘制自定义视图
- 3. 在android中制作自定义组件
- 4. 在Android中制作自定义菜单
- 5. 自定义SurfaceView在Android中制作transperant
- 6. 如何制作自定义WPF集合?
- 7. 如何制作自定义ActionLink?
- 8. 如何制作KineticJs自定义形状
- 9. 如何制作自定义TextView?
- 10. WCF - 如何制作自定义错误?
- 11. R格:如何制作自定义轴
- 12. 如何制作自定义基本UITableViewCell?
- 13. 如何制作自定义小部件?
- 14. 如何制作自定义Windows服务?
- 15. 如何制作自定义jquery日历...............?
- 16. 如何制作自定义容器?
- 17. 如何制作自定义html控件
- 18. 如何制作pentaho自定义组件?
- 19. 如何制作自定义单元格?
- 20. 如何制作自定义文本框?
- 21. 如何制作自定义Eclipse构建?
- 22. 如何制作自定义fontawsome图标?
- 23. 如何制作自定义键盘?
- 24. Android:如何制作自定义应用信息菜单
- 25. 如何在Android上制作自定义字典
- 26. 如何在android应用程序中制作自定义日历?
- 27. 我该如何制作此自定义控件和Android
- 28. 如何制作下图中显示的自定义android按钮?
- 29. android-how如何制作自定义切换按钮
- 30. 如何在Android中制作自定义进度栏?
对不起,你能扩大你的问题吗?或者也许让它更干净?我认为你的是一个设计/图形问题 – StErMi
雅,但我想问它的可行性。 – Basbous