वाले समूहों के लिए सूचक दिखा रहा है मैं डेटाबेस से डेटा के साथ ExpandableListView
बना रहा हूं। इसके लिए, मैं CursorTreeAdapter
का उपयोग कर रहा हूं और मैं इसे Cursor
ऑब्जेक्ट के साथ पॉप्युलेट करता हूं जिसमें डेटा से मैं डेटा पुनर्प्राप्त करता हूं।विस्तारणीय लिस्ट व्यू कोई बच्चे
मैंने सोचा कि डिफ़ॉल्ट रूप से एंड्रॉइड किसी बच्चे के साथ "विस्तार योग्य नहीं" वाले समूहों पर विचार करेगा।
हालांकि यह अभी भी पंक्ति पर विस्तृत आइकन दिखाता है, और जब मैं इसे क्लिक करता हूं, तो यह कुछ भी नहीं करता है। मैं यह आइकन नहीं दिखाना चाहता हूं।
मैं केवल उन समूहों को चाहता हूं जिनके पास विस्तारित आइकन दिखाने के लिए बच्चे हैं, जो नहीं हो रहा है। यह सभी पंक्तियों के लिए विस्तृत आइकन दिखाता है (बच्चे के साथ और बिना बच्चे के)।
अद्यतन
मैं अपने कोड का अध्ययन किया है और मैंने देखा है कि समस्या समूहों के लिए groupIndicator
की स्थापना में मूल रूप से है। हालांकि मैं drawable राज्य और विस्तार पर आधारित है एक चयनकर्ता को बनाने और उसे स्थापित करने की तरह दृष्टिकोण का एक बहुत कोशिश की है इस तरह,:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_empty="true"
android:state_expanded="false"
android:drawable="@android:color/transparent"/>
<item android:drawable="@drawable/expander_ic_maximized" />
</selector>
लेकिन जब समूह संकुचित हो जाता है यह बच्चों के साथ उन सहित सभी समूहों के लिए खाल (क्योंकि एंड्रॉइड ने खाली समूह को खाली के रूप में पहचाना)।
केवल बच्चों के साथ समूहों के लिए सूचक सेट करने के लिए कोई बेहतर तरीका?
यहां मेरा कोड है।
public class ContactsExpandableListAdapter extends CursorTreeAdapter
{
TextView mContactNameTextView, mContactNumberTextView;
Cursor mChildrenCursor = null;
public ContactsExpandableListAdapter(Cursor cursor, Context context)
{
super(cursor, context);
}
@Override
protected Cursor getChildrenCursor(Cursor cursor)
{
if(mContactId == -1)
mContactId = null;
return mController.getContactById(mContactId);
}
public int getChildrenCount(int groupPosition)
{
return mChildrenCursor.getCount();
}
@Override
protected View newGroupView(Context context, Cursor cursor, boolean paramBoolean, ViewGroup viewGroup)
{
View view = LayoutInflater.from(context).inflate(R.layout.filterbycontact, viewGroup, false);
mContactNameTextView = (TextView) view.findViewById(R.id.contact_name);
if(cursor.getString(cursor.getColumnIndex("contact_name")) == null) mContactNameTextView.setText(cursor.getString(cursor.getColumnIndex("contact_number")));
else
mContactNameTextView.setText(cursor.getString(cursor.getColumnIndex("contact_name")));
view.setTag(cursor.getString(cursor.getColumnIndex("contact_id")));
return view;
}
@Override
protected View newChildView(Context context, Cursor cursor, boolean paramBoolean, ViewGroup viewGroup)
{
View view = LayoutInflater.from(context).inflate(R.layout.filterbycontact, viewGroup, false);
if(cursor.getString(cursor.getColumnIndex("contact_name")) == null)
{
mContactNameTextView = (TextView) view.findViewById(R.id.contact_name);
mContactNameTextView.setText(cursor.getString(cursor.getColumnIndex("contact_number")));
}
else
{
mContactNumberTextView = (TextView) view.findViewById(R.id.contact_number);
mContactNumberTextView.setText(cursor.getString(cursor.getColumnIndex("contact_number")));
}
view.setTag(cursor.getString(cursor.getColumnIndex("contact_number")));
return view;
}
@Override
protected void bindGroupView(View view, Context paramContext, Cursor cursor, boolean paramBoolean)
{
mContactNameTextView = (TextView) view.findViewById(R.id.contact_name);
if(cursor.getString(cursor.getColumnIndex("contact_name")) == null)
mContactNameTextView.setText(cursor.getString(cursor.getColumnIndex("contact_number")));
else
mContactNameTextView.setText(cursor.getString(cursor.getColumnIndex("contact_name")));
view.setTag(cursor.getString(cursor.getColumnIndex("contact_id")));
}
@Override
protected void bindChildView(View view, Context context, Cursor cursor, boolean paramBoolean)
{
if(cursor.getString(cursor.getColumnIndex("contact_name")) == null)
{
mContactNameTextView = (TextView) view.findViewById(R.id.contact_name);
mContactNameTextView.setText(cursor.getString(cursor.getColumnIndex("contact_number")));
}
else
{
mContactNumberTextView = (TextView) view.findViewById(R.id.contact_number);
mContactNumberTextView.setText(cursor.getString(cursor.getColumnIndex("contact_number")));
}
}
}
मैं एक शून्य विधि में एक दृश्य कैसे वापस करूँगा? हेहेह शायद यह 'newGroupView()' विधि में सही होना चाहिए? बीटीडब्ल्यू ** व्यूहोल्डर ** क्या है और ** सूचक ** क्या है? – rogcg
क्षमा करें। वापसी गलत, सच था। कर्सर एडाप्टर में दृश्य को वापस करने की कोई आवश्यकता नहीं है: डी। व्यूहोल्डर के बारे में (सूचियों में चीजों को गति देने के लिए एक पैटर्न): http://www.youtube.com/watch?v=wDBM6wVEO70&feature=player_detailpage#t=511s –
ऊपर लिंक वह व्यूहोल्डर के बारे में बात करने के लिए तैयार है। फिर वह http://www.youtube.com/watch पर बताता है?v = wDBM6wVEO70 और सुविधा = player_detailpage # t = 511s –