Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9201695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:04:40+00:00 2026-06-17T23:04:40+00:00

Hi need to prepare screen like this Here is my code of expandable list

  • 0

Hi need to prepare screen like this

enter image description here

Here is my code of expandable list view

Adapter class: NewAdapter.java

public class NewAdapter extends BaseExpandableListAdapter {

    public ArrayList<ParentBean> groupItem;
    ArrayList<String> tempChild;
    public ArrayList<Object> Childtem = new ArrayList<Object>();
    public LayoutInflater minflater;
    public Activity activity;

    public NewAdapter(ArrayList<ParentBean> grList, ArrayList<Object> childItem) {
        groupItem = grList;
        this.Childtem = childItem;
    }

    public void setInflater(LayoutInflater mInflater, Activity act) {
        this.minflater = mInflater;
        activity = act;
    }

    @Override
    public Object getChild(int groupPosition, int childPosition) {
        return null;
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return 0;
    }

    @Override
    public View getChildView(int groupPosition, final int childPosition,
            boolean isLastChild, View convertView, ViewGroup parent) {
        tempChild = (ArrayList<String>) Childtem.get(groupPosition);
        TextView text = null;
        if (convertView == null) {
            convertView = minflater.inflate(R.layout.childrow, null);
        }

        text = (TextView) convertView.findViewById(R.id.textView1);
        text.setText(tempChild.get(0));
        text = (TextView) convertView.findViewById(R.id.textView2);
        text.setText(tempChild.get(1));
        text = (TextView) convertView.findViewById(R.id.textView3);
        text.setText(tempChild.get(2));
        convertView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(activity, tempChild.get(childPosition),
                        Toast.LENGTH_SHORT).show();
            }
        });
        return convertView;
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return 1;
    }

    @Override
    public Object getGroup(int groupPosition) {
        return null;
    }

    @Override
    public int getGroupCount() {
        return groupItem.size();
    }

    @Override
    public void onGroupCollapsed(int groupPosition) {
        super.onGroupCollapsed(groupPosition);
    }

    @Override
    public void onGroupExpanded(int groupPosition) {
        super.onGroupExpanded(groupPosition);
    }

    @Override
    public long getGroupId(int groupPosition) {
        return 0;
    }

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded,
            View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if (convertView == null) {
            convertView = minflater.inflate(R.layout.grouprow, null);
            holder = new ViewHolder();
            holder.name=(TextView)convertView.findViewById(R.id.playername);
            holder.team = (TextView) convertView.findViewById(R.id.vs);
            holder.salary = (TextView) convertView.findViewById(R.id.salary);
            convertView.setTag(holder);

        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        ParentBean playerdetails = groupItem.get(groupPosition);
        holder.name.setText(playerdetails.getPlayername());
        holder.team.setText(playerdetails.getPlayerteam());
        holder.salary.setText(playerdetails.getPlayersalary());
        return convertView;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return false;
    }

    private class ViewHolder {
        TextView team;
        TextView name;
        TextView salary;
    }
    class ParentBean{
        String playername,playerteam,playersalary;

        public ParentBean(String playername,String playerteam,String playersalary) {
            this.playername=playername;
            this.playersalary=playersalary;
            this.playerteam=playerteam;
        }

        /**
         * @return the playername
         */
        public String getPlayername() {
            return playername;
        }

        /**
         * @param playername the playername to set
         */
        public void setPlayername(String playername) {
            this.playername = playername;
        }

        /**
         * @return the playerteam
         */
        public String getPlayerteam() {
            return playerteam;
        }

        /**
         * @param playerteam the playerteam to set
         */
        public void setPlayerteam(String playerteam) {
            this.playerteam = playerteam;
        }

        /**
         * @return the playersalary
         */
        public String getPlayersalary() {
            return playersalary;
        }

        /**
         * @param playersalary the playersalary to set
         */
        public void setPlayersalary(String playersalary) {
            this.playersalary = playersalary;
        }

    }
}

Here is my activity : MainActivity.java

public class MainActivity extends ExpandableListActivity implements
        OnChildClickListener {
    Context context;
    ArrayList<ParentBean> groupItem = new ArrayList<ParentBean>();
    ArrayList<Object> childItem = new ArrayList<Object>();
    NewAdapter mNewAdapter;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ExpandableListView expandbleLis = getExpandableListView();
        expandbleLis.setDividerHeight(2);
        expandbleLis.setGroupIndicator(null);
        expandbleLis.setClickable(true);
        expandbleLis.setFocusable(true);
        context=this;
        getData();
        mNewAdapter = new NewAdapter(groupItem, childItem);
        mNewAdapter.setInflater((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE),this);
        getExpandableListView().setAdapter(mNewAdapter);

        expandbleLis.setOnChildClickListener(this);
    }

    public void getData() {
        JsonDataCallback callback=new JsonDataCallback(MainActivity.this) {

            @Override
            public void receiveData(Object object) {
                String jsonData=(String)object;
                setData(jsonData);
            }
        };
        callback.execute("http://111.93.7.119:8080/FirstPickService/Players?sportid=fc2e88e6-ac87-4d27-b6b3-863baa9f06ec",null,null);
    }

    protected void setData(String jsonData) {
        try {
            JSONObject players=new JSONObject(jsonData);
            final JSONArray playersArray=players.getJSONArray("players");
            for(int i=0;i<playersArray.length();i++)
            {
                JSONObject jsonObj=playersArray.getJSONObject(i);
                String teamplayer=jsonObj.getString("playerfullname");
                String psalary=jsonObj.getString("playerprice");
                String strTeamVS=jsonObj.getString("teamid")+"@"+jsonObj.getString("awayteam");
                groupItem.add(mNewAdapter.new ParentBean(teamplayer, psalary, strTeamVS));

                String strsalary = jsonObj.getString("playerpricelong");
                ArrayList<String> child = new ArrayList<String>();
                child.add(psalary);
                child.add(strTeamVS);
                child.add(strsalary);
                childItem.add(child);
            }
            mNewAdapter.notifyDataSetChanged();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }




    @Override
    public boolean onChildClick(ExpandableListView parent, View v,
            int groupPosition, int childPosition, long id) {
        Toast.makeText(MainActivity.this, "Clicked On Child",
                Toast.LENGTH_SHORT).show();
        return true;
    }
}

I am not sure but I have used a button for select, because of that expandable list losing focus and is not showing childrow when click on the listitem…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:04:42+00:00Added an answer on June 17, 2026 at 11:04 pm

    Try making the select button non-focusable in the xml.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cannot prepare a query that I need. I have code: public class Dog
I'm a pdo newbie and need to prepare and execute some php/pdo code: This
I am making game and need to prepare view for level selection. Could you
Need to apply a filter to a file like this: TUPAC_0006:1:1:2554:2356#0/1 0 * 0
I need a little help with drawing pixels on screen. The code I have
We need to prepare part of our EAR for deployment, we usually do this
I created a Java application and need to prepare it to run on any
I need to prepare check list for .Net windows application. It should include security,
I need to create a basic column chart using highcharts. Here's my PHP code:
I'm struggling here a lot really. I need to prepare a form that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.