2011-06-23 6 views
0

私は自分のapp..nowでリストビューを作成しました。テキストのfontcolorを変更して、テキストの背景を無効にして、リストを無効にしたいと思っています。このchnagesを行うことができる場所クレートのlistview..anyoneのコードは、あなたが色とあなたが好きなスタイルを持っている(あなたによって定義される)カスタム列を使用するArrayAdapterを拡張することができます。..リストビューのスタイルを変更する

super.onCreate(icicle); 
     setContentView(R.layout.contact_activity); 
     lv1=(ListView)findViewById(R.id.ListView01);  
     lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , lv_arr)); 
     lv1.setOnItemClickListener(new OnItemClickListener() 
     { 

      public void onItemClick(AdapterView<?> parent, View view,int position, long id) 
      { 

         String selecteditem = lv_arr[position]; 
         Intent myIntent = new Intent(view.getContext(), ContactInfo.class); 
         myIntent.putExtra("item", selecteditem); 
         startActivity(myIntent); 
      } 
     }); 

答えて

0

ListViewではなく、行を変更する必要があります。 android.R.layout.simple_list_item_1を使用する代わりに、setAdapterを呼び出すときに、あなたのスタイルに合った独自の行レイアウトを作成します。例えば

<?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="wrap_content" 
    android:orientation="horizontal" 
> 
<ImageView 
android:id="@+id/icon" 
android:padding="2dip" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:src="@drawable/tick" 
/> 
<TextView 
    android:id="@+id/label" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textSize="40sp" 
/> 
</LinearLayout 

このレイアウトは右に左と (素敵な大きなフォントで)テキスト上のアイコンで、行を設定するのLinearLayoutを使用しています。

次に、あなたの.setAdapterは次のようになります。

lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.row , lv_arr)); 

希望これは、おそらくあなたが少しを明確にでき、あなたが無効になっリストを望んで何を意味するかかなり確実ではない、あなたが始めるのに役立ちます!

+0

ありがとうございます – AndroidDev

関連する問題