स्पर्श किए जाने पर बच्चे के आइटम फोकस नहीं करते हैं, इसलिए मैंने एक विस्तारणीय लिस्ट व्यू और उप-वर्गीकृत बेसएक्सपैंडेबल लिस्ट एडाप्टर लिखा है ... सबकुछ ठीक काम करता है सिवाय इसके कि मैं क्लिक किए जाने पर ध्यान देने के लिए बच्चे के विचार नहीं प्राप्त कर सकता। अगर मैं ट्रैकबॉल का उपयोग करता हूं तो सब कुछ ठीक काम करता है। लेकिन अगर मैं किसी बच्चे पर क्लिक करने की कोशिश करता हूं तो मुझे कोई प्रतिक्रिया नहीं मिलती है।विस्तारणीय लिस्ट व्यू
मैंने एंड्रॉइड सेटिंग करने की कोशिश की है: फोकस करने योग्य, एंड्रॉइड: फोकस करने योग्य इंटचोडोड, और एंड्रॉइड: क्लिक करने योग्य (और मैंने कोड के माध्यम से इसे सेट करने का भी प्रयास किया है) लेकिन मुझे काम करने के लिए कुछ भी नहीं मिल रहा है। कोई विचार?
public class ExpandableAppAdapter extends BaseExpandableListAdapter
{
private PackageManager m_pkgMgr;
private Context m_context;
private List<ApplicationInfo> m_groups;
private List<List<ComponentName>> m_children;
public ExpandableAppAdapter(Context context, List<ApplicationInfo> groups, List<List<ComponentName>> children)
{
m_context = context;
m_pkgMgr = m_context.getPackageManager();
m_groups = groups;
m_children = children;
}
@Override
public Object getChild(int groupPos, int childPos)
{
return m_children.get(groupPos).get(childPos);
}
@Override
public long getChildId(int groupPos, int childPos)
{
return childPos;
}
@Override
public int getChildrenCount(int groupPos)
{
return m_children.get(groupPos).size();
}
@Override
public View getChildView(int groupPos, int childPos, boolean isLastChild, View convertView, ViewGroup parent)
{
if (convertView == null)
{
LayoutInflater inflater = LayoutInflater.from(m_context);
convertView = inflater.inflate(R.layout.expandable_app_child_row, null);
}
ComponentName child = (ComponentName)getChild(groupPos, childPos);
TextView txtView = (TextView)convertView.findViewById(R.id.item_app_pkg_name_id);
if (txtView != null)
txtView.setText(child.getPackageName());
txtView = (TextView)convertView.findViewById(R.id.item_app_class_name_id);
if (txtView != null)
txtView.setText(child.getClassName());
convertView.setFocusableInTouchMode(true);
return convertView;
}
@Override
public Object getGroup(int groupPos)
{
return m_groups.get(groupPos);
}
@Override
public int getGroupCount()
{
return m_groups.size();
}
@Override
public long getGroupId(int groupPos)
{
return groupPos;
}
@Override
public View getGroupView(int groupPos, boolean isExpanded, View convertView, ViewGroup parent)
{
if (convertView == null)
{
LayoutInflater inflater = LayoutInflater.from(m_context);
convertView = inflater.inflate(R.layout.expandable_app_group_row, null);
}
ApplicationInfo group = (ApplicationInfo)getGroup(groupPos);
ImageView imgView = (ImageView)convertView.findViewById(R.id.item_selection_icon_id);
if (imgView != null)
{
Drawable img = m_pkgMgr.getApplicationIcon(group);
imgView.setImageDrawable(img);
imgView.setMaxWidth(20);
imgView.setMaxHeight(20);
}
TextView txtView = (TextView)convertView.findViewById(R.id.item_app_name_id);
if (txtView != null)
txtView.setText(m_pkgMgr.getApplicationLabel(group));
return convertView;
}
@Override
public boolean hasStableIds()
{
return false;
}
@Override
public boolean isChildSelectable(int groupPos, int childPos)
{
return true;
}
}
अग्रिम धन्यवाद:
यहाँ मेरी एडाप्टर कोड है!
मुझे एक विस्तृत समस्याएं हैं जो एक विस्तारित लिस्ट व्यू में प्रोग्रामेटिक रूप से फ़ोकस प्रबंधित करने का प्रयास कर रही हैं। आपका 'wrap_content' फ़िक्स क्यों काम करता है मुझे बढ़ाता है। – Mark
तकनीकी रूप से इसे एक टिप्पणी के रूप में जोड़ा जाना चाहिए था और उत्तर के रूप में नहीं ... – Justin
मुझे यकीन नहीं है कि यह क्यों काम करता है लेकिन यह मेरे लिए काम करता है – Justin