<分区>
Possible Duplicate:
How to add a button to PreferenceScreen
我想在preference activity的底部添加自定义 View ,还想实现屏幕中添加的 View 的onClick?当我尝试在首选项屏幕中使用布局充气器添加 View 时,它始终位于首选项 View 的顶部。但我想在首选项屏幕底部显示我的 View 。
以下是在首选项 Activity 中添加布局的代码 fragment 。
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.bottom_preference, null, true);
RelativeLayout.LayoutParams rl=new RelativeLayout.LayoutParams(android.widget.RelativeLayout.LayoutParams.MATCH_PARENT,android.widget.RelativeLayout.LayoutParams.MATCH_PARENT);
rl.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
addContentView(view,rl);