2013-07-30 201 views
0

請看看下面的圖片如何創建一個複選框,其左側有「文本」,右側有框?

enter image description here

我動態使用下面的代碼

scrollView = (ScrollView)findViewById(R.id.scrollView); 
    internalTableLayout = new TableLayout(this); 

    for(int i=0;i<20;i++) 
    { 
     CheckBox c = new CheckBox(this); 
     c.setText("Word "+i); 

     TableRow r = new TableRow(this); 
     r.addView(c); 

     internalTableLayout.addView(r); 
    } 

    scrollView.addView(internalTableLayout); 

然而創建這些複選框,我需要這些複選框出現在右側。所以,你知道什麼時候是右邊的,複選框的「文本」首先出現,然後複選框出現。

我該怎麼做?請幫忙。

+0

請參閱我的回答做一個更好的辦法: [如何顯示在右側的Android複選框?] [1] [1]:HTTP://計算器.com/questions/3156781/how-to-show-android-checkbox-at-right-side/21991349#21991349 – Hazhir

回答

1

你可以做什麼Slartibartfast建議或創建一個標籤爲「」的複選框,並添加一個單獨的TextView到左邊,如果這不適合你的幻想。

+0

Ya,我用這個。謝謝:) –

5

如果你想使用CheckBox小部件並實現相同,那麼你可以做這樣的事情。

android:button="@null" 
android:drawableRight="?android:attr/listChoiceIndicatorMultiple" 
+0

這個!非常感謝你。對於那些正在查找這些默認屬性列表的用戶,它們在SDK平臺安裝的/res/values/attrs.xml中定義。 –

相關問題