2011-12-14 12 views
-1

listviewの各行をカスタマイズできるかどうか知りたいですか?いくつかの行にチェックボックスを追加したい、別のボタンなどにボタンを追加したい。* .xmlファイルをどのようにビルドするか?Android ListViewの各行をカスタマイズするにはどうすればよいですか?

ありがとうございます!

+1

はい、可能です。あなたには、多数のチュートリアルがあります。あなたは誰かが答える時間を無駄にしています。 –

+0

http://stackoverflow.com/questions/8476217/two-views-in-each-list-item/8476380#8476380 原則は同じです。 – Jave

答えて

1

あなたは次のような通常のレイアウトファイルを書き込むことができます:あなたのリストビューアダプタ機能で次に

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" android:id="@+id/lineItem"> 
    <!-- The attribute name --> 
    <TextView android:id="@+id/attributeName" android:layout_height="wrap_content" 
    android:layout_width="wrap_content" android:layout_alignParentLeft="true" 
    android:textStyle = "bold" android:paddingTop = "2dp" android:textSize="16dp"/> 

    <!-- The attribute value just beneath the attribute name --> 
    <TextView android:id="@+id/attributeValue" android:layout_height="wrap_content" 
    android:layout_width="wrap_content" android:layout_alignParentLeft="true" 
    android:layout_below="@id/attributeName" android:textSize="12dp" android:paddingBottom="2dp" /> 

    <!-- Now create button besides the line with right align --> 
    <Button android:layout_width="wrap_content" 
    android:background="@drawable/printbutton" 
    android:layout_height="wrap_content" 
    android:id="@+id/printbtn" 
    android:layout_centerInParent="true" android:layout_alignParentBottom="true"></Button> 
</RelativeLayout> 

public View getView(final int position, View convertView, ViewGroup parent) 

あなたはこれが何であるか

convertView = mInflater.inflate(R.layout.listviewrow,null); 

ラインを使用することができます私はやった。 (おそらくListAdapterまたはArrayAdapterから)カスタムアダプタを作成するにつながる

0

えええええええええええええええええええええええんカスタムArrayAdapterを開発する必要があります。 チュートリアルhere

私はそれがあなたの役に立つと思います。

関連する問題