0

有一个很好的解释,这可能对任何试图做同样的人有用!!!

   public class ExpList extends ExpandableListActivity
{
 String gametype;

  // strings for group elements

    static final String arrGroupelements[] = 
    {
   "POKER TOURNAMENTS",
   "SLOTS TOURNAMENTS",
   "ROULLETTE/CRAPS TOURNAMENTS",
   "BLACKJACK TOURNAMENTS",
   "BINGO/CHARITY BINGO"
 };


  // strings for child elements

 static final String arrChildelements[][] = 
 {
   {
  "TEXAS HOLD'EM",
  "OMAHA HIGH-LOW",
  "SEVEN CARD STUD",
  "THREE CARD POKER",
  "OTHER POKER VARIANTS",
  "ONLINE/SATTELITE TOURNAMENTS"
   },
   {
  "SLOTS"
   },
   {
  "ROULLETTE",
  "CRAPS"

   },
   {
  "BLACKJACK"
   },
   {
       "BINGO"
        }
    };    

并按以下方式处理 onChildClick 函数,以在下面单击该子项时将字符串的值设置为“TEXAS HOLD 'EM”

@Override
        public boolean onChildClick(ExpandableListView parent, View v,
                int groupPosition, int childPosition, long id) {
            //ExpandableListAdapter adapter = getExpandableListAdapter();
            gametype = ExpList.arrChildelements[groupPosition][childPosition];
            //---------------------
            Intent pullt = new Intent(ExpList.this,
                    SearchActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("gametype", gametype);
            pullt.putExtras(bundle);
            pullt.putExtra("gametype", gametype);

            startActivity(pullt);
            //---------------------
            return false;
        }
4

2 回答 2

0
public class ExpList extends ExpandableListActivity
{
 String gametype;

  // strings for group elements

    static final String arrGroupelements[] = 
    {
   "POKER TOURNAMENTS",
   "SLOTS TOURNAMENTS",
   "ROULLETTE/CRAPS TOURNAMENTS",
   "BLACKJACK TOURNAMENTS",
   "BINGO/CHARITY BINGO"
 };


  // strings for child elements

 static final String arrChildelements[][] = 
 {
   {
  "TEXAS HOLD'EM",
  "OMAHA HIGH-LOW",
  "SEVEN CARD STUD",
  "THREE CARD POKER",
  "OTHER POKER VARIANTS",
  "ONLINE/SATTELITE TOURNAMENTS"
   },
   {
  "SLOTS"
   },
   {
  "ROULLETTE",
  "CRAPS"

   },
   {
  "BLACKJACK"
   },
   {
       "BINGO"
        }
    };    

并按以下方式处理 onChildClick 函数,以在下面单击该子项时将字符串的值设置为“TEXAS HOLD 'EM”

@Override
        public boolean onChildClick(ExpandableListView parent, View v,
                int groupPosition, int childPosition, long id) {
            //ExpandableListAdapter adapter = getExpandableListAdapter();
            gametype = ExpList.arrChildelements[groupPosition][childPosition];
            //---------------------
            Intent pullt = new Intent(ExpList.this,
                    SearchActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("gametype", gametype);
            pullt.putExtras(bundle);
            pullt.putExtra("gametype", gametype);

            startActivity(pullt);
            //---------------------
            return false;
        }
于 2012-05-24T20:32:58.563 回答
0

onChildClick()你得到groupPositionchildPosition

ExpandableListAdapter adapter = getExpandableListAdapter();
gametype = adapter.getChild(groupPosition, childPosition).toString;
于 2012-05-24T17:16:17.363 回答