Note that there are some explanatory texts on larger screens.

plurals
  1. POExpandableListView onChildClickListener
    primarykey
    data
    text
    <p>I am a new bee to android.</p> <p>I am working with ExpandableListViewAdapter and facing a problem.</p> <p>The onChildClickListener is not working when I click on the edit text box.</p> <p>My question is will it work on edit text box or not.</p> <p>I am implementing the BaseExpandableListAdapter.</p> <p>Thanks in advance.</p> <pre><code>public class TryExpandableListViewActivity extends Activity implements OnChildClickListener { LinearLayout llayout; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); llayout = (LinearLayout) findViewById(R.id.llayout); ExpandableListView list = new ExpandableListView(this); list.setGroupIndicator(null); list.setChildIndicator(null); String[] titles = {"A","B","C"}; String[] fruits = {"a1","a2"}; String[] veggies = {"b1","b2","b3"}; String[] meats = {"c1","c2"}; String[][] contents = {fruits,veggies,meats}; SimplerExpandableListAdapter adapter = new SimplerExpandableListAdapter(this,titles, contents); list.setAdapter(adapter); llayout.addView(list); list.setOnChildClickListener(this); } @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { Log.i("Test","-------------------------------------------"); return false; } </code></pre> <p>}</p> <pre><code>class SimplerExpandableListAdapter extends BaseExpandableListAdapter { private Context mContext; private String[][] mContents; private String[] mTitles; public SimplerExpandableListAdapter(Context context, String[] titles, String[][] contents) { super(); if(titles.length != contents.length) { throw new IllegalArgumentException("Titles and Contents must be the same size."); } mContext = context; mContents = contents; mTitles = titles; } @Override public Object getChild(int groupPosition, int childPosition) { return mContents[groupPosition][childPosition]; } @Override public long getChildId(int groupPosition, int childPosition) { return 0; } @Override public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { EditText row = (EditText)convertView; if(row == null) { row = new EditText(mContext); } row.setTypeface(Typeface.DEFAULT_BOLD); row.setText(mContents[groupPosition][childPosition]); return row; } @Override public int getChildrenCount(int groupPosition) { return mContents[groupPosition].length; } @Override public Object getGroup(int groupPosition) { return mContents[groupPosition]; } @Override public int getGroupCount() { return mContents.length; } @Override public long getGroupId(int groupPosition) { return 0; } @Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { TextView row = (TextView)convertView; if(row == null) { row = new TextView(mContext); } row.setTypeface(Typeface.DEFAULT_BOLD); row.setText(mTitles[groupPosition]); return row; } @Override public boolean hasStableIds() { return false; } @Override public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload