2013-05-14 90 views
0

是有可能包含與TextView的,Editext幷包含與PreferenceScreen第二塊模塊的圖(複選框,列表,Chexbox等)結合的EditText,TextView的和偏好

我想要什麼做這件事,是這樣的。第一個塊有2個EditText和2個TextView for Title和Message。在第二塊(在底部)我想配置一些stoof。

請問我該怎麼做。我希望底部塊看起來像一個列表視圖。當我做懸停在每個項目上,我想這個項目看起來像一個列表視圖項


我試了一下這樣的,但它不工作!我將充氣的類定義爲MyActivity類中的公共靜態類。我究竟做錯了什麼?

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/FrameLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="20dp" 
      android:orientation="vertical" >    
      <view 
       class="com.app.MyActivity$PrefsFragment" 
       id="@+id/prayerFormPref" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       /> 
     </LinearLayout> 
    </ScrollView> 
</FrameLayout> 
+1

是可能的。你可以使用[linearlayout](http://developer.android.com/guide/topics/ui/layout/linear.html)。 – Gunaseelan 2013-05-14 13:21:59

回答

0

每當你想創建一個自定義視圖是隻是一個其他視圖對象的組合,你應該擴展布局(像的LinearLayout,RelativeLayout的等等)。

在擴展布局中,您可以爲子佈局或從XML視圖(使用LayoutInflater)充氣。 或者,您可以使用它們的構造函數和ViewGroup.addView()以編程方式添加所有子視圖。

的SDK指南解釋了這個徹底: http://developer.android.com/guide/topics/ui/custom-components.html#compound

+0

你能告訴我如何創建一個像我在第一篇文章中顯示的圖像嗎? – Mock 2013-05-14 15:04:05

+0

我給出了答案 - 你擴展了一個佈局。 LinearLayout適用於創建標題+ 2項並複製它。你嘗試過嗎? – SirKnigget 2013-05-14 16:21:22

+0

我有上面的代碼,請你檢查一下。非常感謝 – Mock 2013-05-16 08:54:44