मैंने इंटरवेब्स को खराब कर दिया है और सूची चयनकर्ता का उपयोग करके सूची दृश्य के रंगों को बदलने के तरीके के बारे में कई पोस्ट प्राप्त की हैं। हालांकि यह मेरे लिए काम नहीं कर रहा है। तो मेरा सवाल होगा कि मैं क्या गलत कर रहा हूं?एंड्रॉइड सूची दृश्य रंग अनुकूलित करना?
जब मैं नीचे दी गई फ़ाइलों का उपयोग करता हूं तो मुझे एक सूची मिलती है जहां सभी आइटम पृष्ठभूमि प्रारंभ में नीली होती हैं। (मुझे सफेद उम्मीद थी)
जब मैं टेक्स्ट को ऊपर और नीचे फोकस करता हूं तो बस एक गहरे भूरे रंग में बदल जाता है और आइटम पृष्ठभूमि अभी भी नीली होती है। (यह तब होता है जब मैं एक पंक्ति को बाकी सफेद के साथ नीली होने की उम्मीद करता हूं)
जब मैं पंक्ति पर क्लिक करता हूं तो पंक्ति की पृष्ठभूमि मैंने काले रंग की बारी पर क्लिक किया और अन्य सभी पंक्तियां हरे रंग की हो गईं। (मैं पंक्ति मैं हरे हो जाते हैं क्लिक किया होने की संभावना है और बाकी सफेद हो)
यहाँ मेरी मुख्य लेआउट फ़ाइल है:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="10sp">
<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
/>
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textStyle="bold"
android:padding="7dip"
android:textSize="18sp"
android:layout_toRightOf="@id/checkbox"
/>
</RelativeLayout>
यहाँ:
<?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"
>
<ListView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:listSelector="@drawable/item_selector"
/>
<TextView
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/empty"
/>
</LinearLayout>
यहाँ मेरी सूची आइटम फ़ाइल है मेरे रंग दायर किया गया है:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#ff00</color>
<color name="green">#f0f0</color>
<color name="blue">#f00f</color>
<color name="white">#ffff</color>
</resources>
यहाँ मेरी चयनकर्ता फ़ाइल है:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@color/green" />
<item
android:state_focused="true"
android:drawable="@color/blue" />
<item
android:drawable="@color/white" />
</selector>
उम्मीद है कि यह कुछ गूंगा और सरल है कि मैं गलत कर रहा हूं।
अग्रिम धन्यवाद।
यह पूरी सूची की तरह लगता है खुद को व्यक्तिगत सूची आइटमों के बजाय केंद्रित किया जा रहा है। – YGL