0

図に示すように、私は複数の選択肢のリストを持っています

ここに画像の説明を入力してください

私は2つの問題があります

  1. しかし、私のすべてのアプリケーション画面の背景は白です。画面を白にした場合も同じです。デフォルトではテキストの色が白であるため、「BlackBerry」、「Nokia」などのテキストはすべて消えました。方法を教えてください。テキストの色をに変更するには?スタイルを試してみましたが、うまくいきません。

  2. チェックされた位置に問題があります。たとえば、アイテムの1つをチェックし、後でチェックを外すと、チェックを外してもアイテムが選択されていることが表示されます。

チェックされたアイテムを選択するための私のコードは次のとおりです

private void doDownloading() {
        SparseBooleanArray sp = listTrackView.getCheckedItemPositions();

        for (int i = 0; i < sp.size(); i++) {
            selectedConferenceList.add(conferenceList.get(sp.keyAt(i))
                    .getConferenceName());
        }

}

4

2 に答える 2

0

これはサンプルコードであり、自分のコードとして変更できます

AndroidMultiChoiceListActivity .java

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class AndroidMultiChoiceListActivity extends Activity {

 ListView choiceList;
 String[] choice = { "Choice A", 
   "Choice B", "Choice C", "Choice D", "Choice E"};

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        choiceList = (ListView)findViewById(R.id.list);

        ArrayAdapter<String> adapter
        = new ArrayAdapter<String>(this, 
          android.R.layout.simple_list_item_multiple_choice, 
          choice);
        choiceList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
        choiceList.setAdapter(adapter);

    }
}

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    android:textColor="#334422"
    />
<ListView 
    android:id="@+id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />
</LinearLayout>

Textviewandroid:textColor="#334422"で、テキストの色を変更するために使用します。

于 2012-05-02T11:10:08.613 に答える
0

ついに、多肢選択式リストビューのテキストの色を標準で変更できる方法がないことを知りましたArrayAdapter<String>。だから私はカスタムアダプタの実装に行きます。 このリンクは、複数選択の実装を備えたカスタムアダプタを開発する際に役立ちます。

于 2014-02-26T06:14:57.940 に答える