0

たとえば、私は持っています。2 つの親アイテム。1 つ目は 1 つの子を持ち、2 つ目は 3 つの子を持ちます。表示方法。また、2 番目の親ビューがある場合、このビューをクリックしてログを見つけることができませんでした。このビューがログをクリックしたことを知りたいです。

私は何度も同じ名前を持っているので、一度同じ名前を表示して、子供は同じ名前を作ります。

このような

Asia -> Japan

Europe-> Spain
Europe->England

今私は表示したい

Asia->Japan
Europe-> spain
       ->England

Android の展開可能なビューの背後にあるアイデアはあまりありません。

oncreate のコードは次のとおりです。

if (EduInterface.categoryIDArrayList.size() > 0) {

                    categoryName = new String[EduInterface.categoryNameArrayList
                            .size()][];
                    award = new String[EduInterface.pointIDArrayList.size()][];
                    pointName = new String[EduInterface.pointNameArrayList
                            .size()][];
                    pointValue = new String[EduInterface.pointValueArrayList
                            .size()][];

                    System.out.println("size of category name is ::"
                            + categoryName.length);

                    int catList = EduInterface.categoryIDArrayList.size();
                    Log.d("TAG", "Size of Cat===" + catList);
                    for (int j = 0; j < catList; j++)
                    {
                        for (int i = j; i < EduInterface.pointCategoryArrayList
                                .size(); i++) {
                            categoryName[j] = new String[1];
                            categoryName[j][i] = EduInterface.categoryNameArrayList
                                    .get(j);
                            pointName[j] = new String[1];
                            pointName[j][i] = EduInterface.pointNameArrayList
                                    .get(j);
                            pointValue[j] = new String[1];
                            pointValue[j][i] = EduInterface.pointValueArrayList
                                    .get(j);
                            System.out.println(j + ")categoryName is ::"
                                    + categoryName[j][i]
                                    + "  point value is ::" + pointName[j][i]
                                    + "---" + pointValue[j][i]);
                        }
                    }

                    pointcategoryExpandableList
                            .setAdapter(new MyExpandableAdapter());
                }

ExapanableAdater で:

public class MyExpandableAdapter extends BaseExpandableListAdapter {

        @Override
        public Object getChild(int groupPosition, int childPosition) {
            return categoryName[groupPosition][childPosition];
        }

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

        @Override
        @SuppressLint("ResourceAsColor")
        public View getChildView(final int groupPosition, int childPosition,
                boolean isLastChild, View convertView, ViewGroup parent) {
            if (convertView == null) {
                LayoutInflater infalInflater = (LayoutInflater) PointCategory_index.this
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                convertView = infalInflater.inflate(
                        R.layout.point_category_childview, null);
            }

            // View descriptionviewView=(RelativeLayout)
            // convertView.findViewById(R.id.awardButton);
            if (isLastChild) {
                Log.d("TAG", "Last child");
            }
            final TextView awardTextView = (TextView) convertView
                    .findViewById(R.id.award);
            awardTextView.setTextColor(getResources().getColor(
                    R.color.award_color));
            awardTextView.setTypeface(font_regular);

            // for(int i=0;i<)
            /*
             * TextView point = (TextView) convertView
             * .findViewById(R.id.pointTextV); point.setText("Point");
             */
            TextView pointValuetxt = (TextView) convertView
                    .findViewById(R.id.points);
            pointValuetxt.setText(pointValue[groupPosition][childPosition]);
            pointValuetxt.setTypeface(font_regular);

            TextView pointInNumber = (TextView) convertView
                    .findViewById(R.id.pointTextV);
            pointInNumber.setText(pointName[groupPosition][childPosition]);
            pointInNumber.setTypeface(font_regular);

            if (userTypeId.trim().equalsIgnoreCase("4")
                    || userTypeId.trim().equalsIgnoreCase("1")) {
                awardTextView.setVisibility(View.VISIBLE);

                // check usertypeid
                // set point category id
            }

            awardTextView.setOnClickListener(new OnClickListener() {
                // int x=groupPosition;
                @Override
                public void onClick(View v) {
                    awardTextView.setTextColor(getResources().getColor(
                            R.color.green));

                    String id = EduInterface.pointIDArrayList
                            .get(groupPosition); // /Here change by dharma
                                                    // (categoryID->pointID)
                    Log.d("TAG", "Point Id test---->>>>>>" + id);
                    editor.putString("pointID", id);
                    /*
                     * Log.d("Click Point Id is", id);
                     * Log.d("Click Point Value is",
                     * EduInterface.pointValueArrayList.get(groupPosition));
                     */
                    editor.commit();

                    if (userTypeId.trim().equalsIgnoreCase("1")) {
                        startActivity(new Intent(PointCategory_index.this,
                                ChildActivity.class));// Go to
                                                        // professor
                                                        // List
                    } else if (userTypeId.trim().equalsIgnoreCase("4")) {
                        Log.d("TAG", "Award Button was Clicked !!1");
                        startActivity(new Intent(PointCategory_index.this,
                                PointCategory_courseList.class));
                    }

                }
            });
            return convertView;
        }

        @Override
        public int getChildrenCount(int groupPosition) {
            return categoryName[groupPosition].length;
        }

        @Override
        public Object getGroup(int groupPosition) {
            return CategoriesIds.get(groupPosition);
        }

        @Override
        public int getGroupCount() {
            // return EduInterface.categoryIDArrayList.size();
            return RemoveDuplicateCat.size();
        }

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

        @Override
        public View getGroupView(int groupPosition, boolean isExpanded,
                View convertView, ViewGroup parent) {
            if (convertView == null) {
                LayoutInflater inflater = (LayoutInflater) PointCategory_index.this
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                convertView = inflater.inflate(
                        R.layout.point_category_groupview, null);
            }
            TextView name = (TextView) convertView
                    .findViewById(R.id.categoryname);
            // name.setText(EduInterface.categoryNameArrayList.get(groupPosition));
            name.setText(RemoveDuplicateCat.get(groupPosition));
            name.setTypeface(font_regular);

            /*
             * convertView.setOnClickListener(new OnClickListener() {
             * 
             * @Override public void onClick(View v) { Log.d("TAG",
             * "TEST->>"+RemoveDuplicateCat.get(groupPosition)); TextView name =
             * (TextView) findViewById(R.id.categoryname);
             * name.setText(RemoveDuplicateCat.get(groupPosition));
             * name.setTypeface(font_regular); } });
             */
            /*
             * name.setOnClickListener(new View.OnClickListener() {
             * 
             * @Override public void onClick(View v) { Log.d("TAG",
             * "Clicking cATEEEE==="+RemoveDuplicateCat.get(groupPosition));
             * 
             * } });
             */
            // RemoveDuplicateCat

            return convertView;
        }

        /*
         * public boolean onChildClick(ExpandableListView parent, View v, int
         * groupPosition, int childPosition, long id) { String test =
         * (String)MyExpandableAdapter.getItem(groupPosition);
         * Log.d("TAG","CLICK->"+test); // update the text view with the country
         * return true; }
         */
        @Override
        public boolean hasStableIds() {
            return true;
        }

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

1 に答える 1