2

こんにちは、私はjsonから3つのレベルの拡張可能なリストビューを作成したい。 私は拡張可能なリストビューを2つの2つのレベルまで持ってきましたが、3つのレベルのために私はそれを完了するために私を助けてくださいどのような身体ドンしてください方法を持っていなかった。 ここに私が作成したコードです。AndroidのJSONから3レベルの展開可能なリストビューを作成する方法は?

私の主な活動

String Tag="MainActivity"; 
private ExpandableListView expandableListView; 
ArrayList<String>mainlist =new ArrayList<>();; 
HashMap<String, List<String>> childContent = new HashMap<String, List<String>>(); 

HashMap<String, HashMap<List<String>,List<String>>> subchildContent = new HashMap<String, HashMap<List<String>,List<String>>>(); 
List<String> childlist; 
List<String> subchildlist; 
private List<String> parentHeaderInformation; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    new ReleaseOverviewReleaseAsynchTask().execute(); 
} 

@Override 
protected void onResume() { 
    super.onResume(); 

    expandableListView = (ExpandableListView)findViewById(R.id.expandableListView); 

    //ExpandableListAdapter expandableListViewAdapter = new ExpandableListAdapter(getApplicationContext(), mainlist, childContent); 
    ChildSubChildExpandableListAdapter adapter=new ChildSubChildExpandableListAdapter(getApplicationContext(),mainlist,childlist,childContent); 
    expandableListView.setAdapter(adapter); 
} 



class ReleaseOverviewReleaseAsynchTask extends AsyncTask<Void,Void,Void> { 


    @Override 
    protected void onPreExecute() { 
     super.onPreExecute(); 
    } 

    @Override 
    protected Void doInBackground(Void... params) { 
     String jsonStr = Util.loadJSONFromAsset(MainActivity.this,"release.json"); 
     if (jsonStr != null) { 
      try { 
       JSONArray array = new JSONArray(jsonStr); 

       for (int i = 0; i < array.length(); i++) { 

        JSONObject jo_object = array.getJSONObject(i); 
        childlist= new ArrayList<String>(); 
        subchildlist= new ArrayList<String>(); 
        String release= jo_object.get("Release").toString(); 
        mainlist.add(jo_object.get("Release").toString()); 
        Log.i("main release",release); 
        JSONArray jsonArrayDetails=jo_object.getJSONArray("details"); 
        if (!jsonArrayDetails.isNull(i)){ 
         JSONObject jo_object1 = jsonArrayDetails.getJSONObject(i); 

         String builddate= jo_object1.get("Build Date").toString(); 
         Log.i(Tag,builddate); 
         String deploydate= jo_object1.get("Deploy Date").toString(); 
         Log.i(Tag,deploydate); 
         String respindate= jo_object1.get("Respin Date").toString(); 
         Log.i(Tag,respindate); 
         String releaselead= jo_object1.get("Release Lead").toString(); 
         Log.i(Tag,releaselead); 
         String engineerlead= jo_object1.get("Engineering Lead").toString(); 
         Log.i(Tag,engineerlead); 
         String testlead=jo_object1.get("Test Lead").toString(); 
         Log.i(Tag,testlead); 


        } 
        JSONArray childarray=jo_object.getJSONArray("children"); 

        for (int i_child = 0; i_child < childarray.length(); i_child++) { 
         JSONObject jo_objectchild = childarray.getJSONObject(i_child); 

         childlist.add(jo_objectchild.get("Release").toString()); 
         Log.i("child release",jo_objectchild.get("Release").toString()); 

         JSONArray subchildarray=jo_objectchild.getJSONArray("children"); 

         for (int i_subchild=0;i_subchild<=subchildarray.length();i_subchild++){ 
          if (!subchildarray.isNull(i_subchild)){ 
           JSONObject jo_objectsubchild = subchildarray.getJSONObject(i_subchild); 
           Log.i("sub release",jo_objectsubchild.get("Release").toString()); 
           subchildlist.add(jo_objectsubchild.get("Release").toString()); 
          } 

          /*JSONObject jo_objectsubchild = subchildarray.getJSONObject(i_subchild); 
          */ 
         } 



        } 
        childContent.put(mainlist.get(i),subchildlist); 
       } 


      } 
      catch (JSONException e) { 
       e.printStackTrace(); 
      } 
     } 
     else{ 
      // Log.e(TAG, "Couldn't get json from server."); 
      runOnUiThread(new Runnable() { 
       @Override 
       public void run() { 
        Toast.makeText(getApplicationContext(), 
          "Couldn't get json from server. Check LogCat for possible errors!", 
          Toast.LENGTH_LONG) 
          .show(); 
       } 
      }); 

     } 
     return null; 
    } 

私の親拡張可能なリストビューは、ここで

public class ExpandableListAdapter extends BaseExpandableListAdapter { 
private Context context; 
private List<String> parentDataSource; 
private HashMap<String, List<String>> childDataSource; 

private HashMap<String, List<String>> subchildDataSource; 

public ExpandableListAdapter(Context context, List<String> childParent, HashMap<String, List<String>> child){ 

    this.context = context; 

    this.parentDataSource = childParent; 

    this.childDataSource = child; 
} 
@Override 
public int getGroupCount() { 
    return this.parentDataSource.size(); 
} 

@Override 
public int getChildrenCount(int groupPosition) { 
    return this.childDataSource.get(this.parentDataSource.get(groupPosition)).size(); 
} 

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

} 

@Override 
public Object getChild(int groupPosition, int childPosition) { 
    return this.childDataSource.get(parentDataSource.get(groupPosition)).get(childPosition); 
} 

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

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

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

@Override 
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { 
    View view = convertView; 
    if(view == null){ 

     LayoutInflater inflater = (LayoutInflater)this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

     view = inflater.inflate(R.layout.parentlayout, parent, false); 

    } 
    String parentHeader = (String)getGroup(groupPosition); 

    TextView parentItem = (TextView)view.findViewById(R.id.parent_layout); 

    parentItem.setText(parentHeader); 
    notifyDataSetChanged(); 
    return view; 
} 

@Override 
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { 
    View view = convertView; 

    if(view == null){ 

     LayoutInflater inflater = (LayoutInflater)this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

     view = inflater.inflate(R.layout.childlayout, parent, false); 

    } 
    String childName = (String)getChild(groupPosition, childPosition); 

    TextView childItem = (TextView)view.findViewById(R.id.child_layout); 

    childItem.setText(childName); 
    notifyDataSetChanged(); 
    return view; 
} 

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

である3つのレベルのための拡張可能なリストは、その

public class ChildSubChildExpandableListAdapter extends 
BaseExpandableListAdapter{ 

Context context; 
HashMap<String, List<String>> childdata; 

private List<String> parentDataSource; 
List<String> secondLevel; 
private HashMap<String, List<String>> childDataSource; 

public ChildSubChildExpandableListAdapter(Context context, List<String> Parent, List<String> secondLevel, HashMap<String, List<String>> data) { 
    this.context = context; 

    this.parentDataSource = Parent; 

    this.secondLevel = secondLevel; 

    this.childdata = data; 


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

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

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

@Override 
public Object getChild(int i, int i1) { 
    return i1; 
} 

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

@Override 
public long getChildId(int i, int i1) { 
    return i1; 
} 

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

@Override 
public View getGroupView(int groupPosition, boolean b, View convertView, ViewGroup viewGroup) { 
    View view = convertView; 
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    convertView = inflater.inflate(R.layout.parentlayout, null); 
    TextView text = (TextView) convertView.findViewById(R.id.parent_layout); 
    text.setText(this.parentDataSource.get(groupPosition)); 
    return convertView; 
} 

@Override 
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup group) { 
    final SecondLevelExpandableListView secondLevelELV = new SecondLevelExpandableListView(context); 

    String headers =secondLevel.get(groupPosition); 
    List<String> header=new ArrayList<>(); 
    header.add(headers); 
    List<List<String>> childData = new ArrayList<>(); 
    HashMap<String, List<String>> secondLevelData= (HashMap<String, List<String>>) childdata.get(groupPosition); 
    for(String key : secondLevelData.keySet()) 
    { 


     childData.add(secondLevelData.get(key)); 

    } 

    secondLevelELV.setAdapter(new ExpandableListAdapter(context, header,secondLevelData)); 

    secondLevelELV.setGroupIndicator(null); 

    secondLevelELV.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() { 
     int previousGroup = -1; 

     @Override 
     public void onGroupExpand(int groupPosition) { 
      if(groupPosition != previousGroup) 
       secondLevelELV.collapseGroup(previousGroup); 
      previousGroup = groupPosition; 
     } 
    }); 
    return secondLevelELV; 
} 

@Override 
public boolean isChildSelectable(int i, int i1) { 
    return true; 
} 

}

私のために働いていません

ここでは2番目のレベルの展開リストビューです

public class SecondLevelExpandableListView extends ExpandableListView 
    { 

    public SecondLevelExpandableListView(Context context) { 
     super(context); 
    } 

    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 
     //999999 is a size in pixels. ExpandableListView requires a maximum height in order to do measurement calculations. 
     heightMeasureSpec = MeasureSpec.makeMeasureSpec(999999, MeasureSpec.AT_MOST); 
     super.onMeasure(widthMeasureSpec, heightMeasureSpec); 
    } 

こんにちは、私は3つのレベルの拡張を作成するのを手伝ってください。上記のコードは、私がExpandableListAdapterだけを使用する場合に機能します。 は、上記のコードでは、私は

iはリストの各要素にチェックボックスを追加したいと私は子供を選択すると、その親も

を選択する必要があります動作していない3つのレベルのためにchildSubChildAdapterを使用していましたここ

は、この問題で私を助けてください、私のJSON

{ 
"Release": "16.1", 
"details": [], 
"children": [ 
    { 
    "Release": "16.1R3", 
    "details": [ 
     { 
     "Build Date": "", 
     "Deploy Date": "", 
     "Respin Date": "", 
     "Release Lead": "Jl", 
     "Engineering Lead": "LG", 
     "Test Lead": "Dl" 
     } 
    ], 
    "children": [ 
     { 
     "Release": "16.1R3-S5", 
     "details": [ 
      { 
      "Build Date": "2017-08-17", 
      "Deploy Date": "2017-08-25", 
      "Respin Date": "", 
      "Release Lead": "Jk", 
      "Engineering Lead": "Ly", 
      "Test Lead": "FD" 
      } 
     ] 
     } 
    ] 
    } 

です。私はこのタイプの仕事を初めてやっています。事前に

おかげ

+0

に従うよう。 –

答えて

0

私の提案は、大規模なデータの場合には拡張可能なリストビューには、特別に3つのレベルの拡張可能なリストビューの場合には、問題を作成しますので、代わりに拡張可能なリストビューのリサイクルビューを使用することです。

リストボックスレベルのブール値を持つモデルクラスを作成します。

+0

私は何も考えていません、私はそれにいくつかのサンプルを与えることができます –

+0

あなたのJSON資産ファイルのコピーを提供することができます – R7G

+0

はいここJSONのコピーです –

0

こんにちは3つのレベル拡張リストビューのためにあなたは私たちのすべては、我々はすべてのスクロールビューでオブジェクトをスクロールする場所をカント知られているようにcustomExpandableListViewである1以上ExpandableListViewを含むchildviewとExpandableListViewを必要とする、私は私のプロジェクトの一つでこれを行っています次のように、

最初のアダプタである

public class AdminExpandableListAdapter extends BaseExpandableListAdapter { 
    private Context _context; 
    private List<Child> masterData; 
    private Activity activity; 
    private int i = 1; 
    static String masterId; 

    public AdminExpandableListAdapter(Context _context, List<Child> masterData, Activity activity) { 
     this._context = _context; 
     this.masterData = masterData; 
     this.activity = activity; 
    } 

    @Override 
    public Object getChild(int groupPosition, int childPosition) { 
     //return this.masterData.get(groupPosition).getChildren().size(); 
     return childPosition; 
    } 

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

    @Override 
    public int getChildrenCount(int groupPosition) { 
     /* try { 
      return this.masterData.get(groupPosition).getChildren().size(); 
     }catch (Exception e){ 
      e.printStackTrace(); 
      Toast.makeText(AdminExpandableListAdapter.this._context,"Record not found",Toast.LENGTH_LONG).show(); 
      return 0; 
     }*/ 
     return 1; 
    } 

    @Override 
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { 
     List<Child_> dealerData = masterData.get(groupPosition).getChildren(); 
     if (convertView == null) { 
      LayoutInflater inflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      convertView = inflater.inflate(R.layout.item_admin_child_dealer_, null); 
     } 
     LinearLayout dealerchild = (LinearLayout) convertView.findViewById(R.id.linear_layout_item_admin_child); 

     int width = 380; 
     CustExpListview SecondLevelexplv = new CustExpListview(activity, width); 
     SecondLevelexplv.setGroupIndicator(ResourcesCompat.getDrawable(activity.getResources(), R.drawable.group_indicator, null)); 
     AdminDealerChildExpandableAdapter listAdapter = new AdminDealerChildExpandableAdapter(_context, dealerData, activity); 
     SecondLevelexplv.setAdapter(listAdapter); 

     return SecondLevelexplv; 

    } 

    @Override 
    public Object getGroup(int groupPosition) { 
     //return this.masterData.get(groupPosition); 
     return groupPosition; 
    } 

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

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

    @Override 
    public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { 
     String headerTitle = masterData.get(groupPosition).getName(); 
     if (convertView == null) { 
      LayoutInflater inflater = (LayoutInflater) this._context 
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      convertView = inflater.inflate(R.layout.item_admin_group_master_, null); 
     } 
     TextView lblListheader = (TextView) convertView.findViewById(R.id.admin_master_group_text_view); 
     lblListheader.setText(headerTitle); 
     /* lblListheader.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       AdminSelectMaster(groupPosition); 
      } 


     });*/ 
     ImageView settingImageView = (ImageView) convertView.findViewById(R.id.admin_master_group_item_image_view); 
     settingImageView.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       UnSelectChild(activity); 
       AdminSelectMaster(groupPosition); 
       PopupMenu popupMenu = new PopupMenu(activity, v); 
       popupMenu.inflate(R.menu.master_select_dealer_menu); 
       Object menuHelper; 
       Class[] argTypes; 
       popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { 
        @Override 
        public boolean onMenuItemClick(MenuItem item) { 
         switch (item.getItemId()) { 
          case R.id.add_account: 
           // new AddUserAccountDialog(activity, _context); 
           new CreateDealerDialogSelectMasterAdmin(activity); 
           break; 
          case R.id.view_account: 
           new ViewMasterAccountAdminDialog(activity); 

           break; 
          case R.id.change_password: 
           new ChangeMasterPasswordAdminDialog(activity); 
           break; 
          case R.id.free_chip_in_out: 
           new MasterFreeChipInOutAdminDailog(activity); 
           break; 
          case R.id.lock_user: 
           new LockMasterDialogAdmin(activity); 
           break; 
          case R.id.lock_betting: 
           new LockMasterBetDialogAdmin(activity); 
           break; 
          case R.id.close_acc: 
           new CloseMasterAccountDialogAdmin(activity); 
           break; 
         } 
         return false; 
        } 
       }); 
       try { 
        Field fMenuHelper = PopupMenu.class.getDeclaredField("mPopup"); 
        fMenuHelper.setAccessible(true); 
        menuHelper = fMenuHelper.get(popupMenu); 
        argTypes = new Class[]{boolean.class}; 
        menuHelper.getClass().getDeclaredMethod("setForceShowIcon", argTypes).invoke(menuHelper, true); 
       } catch (Exception e) { 
        Log.w("LOG_W", "error forcing menu icons to show", e); 
        popupMenu.show(); 
       } 
       popupMenu.show(); 
      } 
     }); 
     lblListheader.setText(headerTitle); 
     return convertView; 
    } 

    private void AdminSelectMaster(int position) { 
     final App editor = App.getInstance(); 
     editor.setCurrentMasterId(masterData.get(position).getId()); 
     editor.setCurrentMasterType(masterData.get(position).getUsetype()); 
     editor.setCurrentMasterName(masterData.get(position).getName()); 
     editor.setCurrentMasterMstrLock(masterData.get(position).getMstrlock()); 
     editor.setCurrentMasterCommision(masterData.get(position).getCommission()); 
     editor.setCurrentMasterLockbtng(masterData.get(position).getLgnusrlckbtng()); 
     editor.setCurrentMasterCloseAc(masterData.get(position).getLgnusrCloseAc()); 
     editor.setCurrentMasterMastrName(masterData.get(position).getMstrname()); 
     editor.setCurrentMasterPartner(masterData.get(position).getPartner()); 
     editor.setCurrentMasterMaxStake(masterData.get(position).getLgnUserMaxStake()); 
     editor.setCurrentMasterMaxProfit(masterData.get(position).getLgnUserMaxProfit()); 
     editor.setCurrentMasterMaxLoss(masterData.get(position).getLgnUserMaxLoss()); 
     editor.setCurrentMasterSessionCommision(masterData.get(position).getSessionComm()); 
     editor.setCurrentMasterOtherCommision(masterData.get(position).getOtherComm()); 
     ViewMasterAccountAdminDialog.ViewPartnership(editor.getCurrentMasterId()); 
    } 

    public static void UnSelectChild(Activity activity) { 
     final App editor = App.getInstance(); 
     editor.setCurrentChildId(null); 
     editor.setCurrentChildType("null"); 
     editor.setCurrentChildName(null); 
     editor.setCurrentChildMstrLock(null); 
     editor.setCurrentChildCommision(null); 
     editor.setCurrentChildLockbtng(null); 
     editor.setCurrentChildCloseAc(null); 
     editor.setCurrentChildMastrName(null); 
     editor.setCurrentChildPartner(null); 
     editor.setCurrentChildMaxStake(null); 
     editor.setCurrentChildMaxProfit(null); 
     editor.setCurrentChildMaxLoss(null); 

     editor.setCurrentParentId(null); 
     editor.setCurrentParentType("null"); 
     editor.setCurrentParentName(null); 
     editor.setCurrentParentMstrLock(null); 
     editor.setCurrentParentCommision(null); 
     editor.setCurrentParentLockbtng(null); 
     editor.setCurrentParentCloseAc(null); 
     editor.setCurrentParentMastrName(null); 
     editor.setCurrentParentPartner(null); 
     editor.setCurrentParentrMaxStake(null); 
     editor.setCurrentParentMaxProfit(null); 
     editor.setCurrentParentMaxLoss(null); 

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

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

第CustomExpandableListView

public class CustExpListview extends ExpandableListView { 

    int width; 

    public CustExpListview(Context context, int width) { 
     super(context); 
     this.width = width; 
    } 

    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 
     widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, 
       MeasureSpec.EXACTLY); 
     heightMeasureSpec = MeasureSpec.makeMeasureSpec(900, 
       MeasureSpec.AT_MOST); 
     /*widthMeasureSpec = ViewGroup.LayoutParams.MATCH_PARENT; 
     heightMeasureSpec = ViewGroup.LayoutParams.WRAP_CONTENT;*/ 
     super.onMeasure(widthMeasureSpec, heightMeasureSpec); 
    } 
} 

サードchildView ExpandableListViewアダプタ正常に動作しないチェックボックスexpandableListviewで

public class AdminDealerChildExpandableAdapter extends BaseExpandableListAdapter { 
    Context _context; 
    Activity activity; 
    private List<Child_> dealerData; 

    public AdminDealerChildExpandableAdapter(Context _context, List<Child_> dealerData, Activity activity) { 
     this._context = _context; 
     this.dealerData = dealerData; 
     this.activity = activity; 
    } 

    @Override 
    public Object getChild(int groupPosition, int childPosition) { 
     //return this.dealerData.get(groupPosition).getChildren().size(); 
     return childPosition; 
    } 

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

    @Override 
    public int getChildrenCount(int groupPosition) { 
     try { 
      return this.dealerData.get(groupPosition).getChildren().size(); 
     } catch (Exception e) { 
      e.printStackTrace(); 

      return 0; 
     } 
    } 

    @Override 
    public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { 
     final String childtext = dealerData.get(groupPosition).getChildren().get(childPosition).getName(); 
     if (convertView == null) { 
      LayoutInflater inflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      convertView = inflater.inflate(R.layout.list_item_user_child, null); 
     } 
     TextView txtChild = (TextView) convertView.findViewById(R.id.lblListItem); 
     txtChild.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       AdminUserSelect(groupPosition,childPosition); 
      } 
     }); 
     ImageView settingImageView = (ImageView) convertView.findViewById(R.id.master_user_child_item_image_view); 
     settingImageView.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       PopupMenu popupMenu = new PopupMenu(activity, v); 
       popupMenu.inflate(R.menu.dealer_select_user_menu); 
       Object menuHelper; 
       Class[] argTypes; 
       AdminUserSelect(groupPosition, childPosition); 
       //AdminUnSelectDealer(activity); 
       popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { 
        @Override 
        public boolean onMenuItemClick(MenuItem item) { 
         switch (item.getItemId()) { 
          case R.id.add_account: 
           new AddUserAccountDialog(activity, _context); 
           break; 
          case R.id.view_account: 
           new ViewUserAccountAdminDialog(activity); 
           break; 
          case R.id.change_password: 
           new ChangePasswordUserDialog(activity, _context); 
           break; 
          case R.id.free_chip_in_out: 
           new UserFreeChipInOutDailog(activity, _context); 
           break; 
          case R.id.lock_user: 
           new LockUserDialog(activity, _context); 
           break; 
          case R.id.lock_betting: 
           new LockUserBetDialog(activity, _context); 
           break; 
          case R.id.close_acc: 
           new CloseUserAccountDialog(activity, _context); 
           break; 
         } 
         return false; 
        } 
       }); 
       try { 
        Field fMenuHelper = PopupMenu.class.getDeclaredField("mPopup"); 
        fMenuHelper.setAccessible(true); 
        menuHelper = fMenuHelper.get(popupMenu); 
        argTypes = new Class[]{boolean.class}; 
        menuHelper.getClass().getDeclaredMethod("setForceShowIcon", argTypes).invoke(menuHelper, true); 
       } catch (Exception e) { 
        Log.w("LOG_W", "error forcing menu icons to show", e); 
        popupMenu.show(); 
       } 
       popupMenu.show(); 
      } 
     }); 
     txtChild.setText(childtext); 
     return convertView; 
    } 

    private void AdminUnSelectDealer(Activity activity) { 
     final App editor = (App) activity.getApplicationContext(); 
     editor.setCurrentParentId(null); 
     editor.setCurrentParentType("null"); 
     editor.setCurrentParentName(null); 
     editor.setCurrentParentMstrLock(null); 
     editor.setCurrentParentCommision(null); 
     editor.setCurrentParentLockbtng(null); 
     editor.setCurrentParentCloseAc(null); 
     editor.setCurrentParentMastrName(null); 
     editor.setCurrentParentPartner(null); 
     editor.setCurrentParentrMaxStake(null); 
     editor.setCurrentParentMaxProfit(null); 
     editor.setCurrentParentMaxLoss(null); 

    } 

    private void AdminUserSelect(int groupPosition, int childPosition) { 
     AdminSelectDealer(groupPosition); 
     final App editor = (App) activity.getApplicationContext(); 
     editor.setCurrentChildId(dealerData.get(groupPosition).getChildren().get(childPosition).getId()); 
     editor.setCurrentChildType(dealerData.get(groupPosition).getChildren().get(childPosition).getUsetype()); 
     editor.setCurrentChildName(dealerData.get(groupPosition).getChildren().get(childPosition).getName()); 
     editor.setCurrentChildMstrLock(dealerData.get(groupPosition).getChildren().get(childPosition).getMstrlock()); 
     editor.setCurrentChildCommision(dealerData.get(groupPosition).getChildren().get(childPosition).getCommission()); 
     editor.setCurrentChildLockbtng(dealerData.get(groupPosition).getChildren().get(childPosition).getLgnusrlckbtng()); 
     editor.setCurrentChildCloseAc(dealerData.get(groupPosition).getChildren().get(childPosition).getLgnusrCloseAc()); 
     editor.setCurrentChildMastrName(dealerData.get(groupPosition).getChildren().get(childPosition).getMstrname()); 
     editor.setCurrentChildPartner(dealerData.get(groupPosition).getChildren().get(childPosition).getPartner()); 
     editor.setCurrentChildMaxStake(dealerData.get(groupPosition).getChildren().get(childPosition).getLgnUserMaxStake()); 
     editor.setCurrentChildMaxProfit(dealerData.get(groupPosition).getChildren().get(childPosition).getLgnUserMaxProfit()); 
     editor.setCurrentChildMaxLoss(dealerData.get(groupPosition).getChildren().get(childPosition).getLgnUserMaxLoss()); 
     ViewUserAccountAdminDialog.ViewPartnership(editor.getCurrentChildId()); 

    } 

    @Override 
    public Object getGroup(int groupPosition) { 
     return groupPosition; 
     //return this.dealerData.get(groupPosition); 
    } 

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

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

    @Override 
    public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { 
     String headerTitle = dealerData.get(groupPosition).getName(); 
     if (convertView == null) { 
      LayoutInflater inflater = (LayoutInflater) this._context 
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      convertView = inflater.inflate(R.layout.list_group_header, null); 
     } 
     TextView lblListheader = (TextView) convertView.findViewById(R.id.list_group_item); 
     ImageView settingImageView = (ImageView) convertView.findViewById(R.id.master_dealer_group_item_image_view); 
     settingImageView.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       UnSelectChild(activity); 
       AdminSelectDealer(groupPosition); 
       PopupMenu popupMenu = new PopupMenu(activity, v); 
       popupMenu.inflate(R.menu.master_select_dealer_menu); 
       Object menuHelper; 
       Class[] argTypes; 
       popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { 
        @Override 
        public boolean onMenuItemClick(MenuItem item) { 
         switch (item.getItemId()) { 
          case R.id.add_account: 
           new AddUserAccountDialog(activity, _context); 
           break; 
          case R.id.view_account: 
           new ViewDealerAccountAdminDialog(activity); 
           break; 
          case R.id.change_password: 
           new ChangeDealerPasswordDialog(activity, _context); 
           break; 
          case R.id.free_chip_in_out: 
           new DealerFreeChipInOutDailog(activity, _context); 
           break; 
          case R.id.lock_user: 
           new LockDealerDialog(activity, _context); 
           break; 
          case R.id.lock_betting: 
           new LockDealerBetDialog(activity, _context); 
           break; 
          case R.id.close_acc: 
           new CloseDealerAccountDialog(activity, _context); 
           break; 
         } 
         return false; 
        } 
       }); 
       try { 
        Field fMenuHelper = PopupMenu.class.getDeclaredField("mPopup"); 
        fMenuHelper.setAccessible(true); 
        menuHelper = fMenuHelper.get(popupMenu); 
        argTypes = new Class[]{boolean.class}; 
        menuHelper.getClass().getDeclaredMethod("setForceShowIcon", argTypes).invoke(menuHelper, true); 
       } catch (Exception e) { 
        Log.w("LOG_W", "error forcing menu icons to show", e); 
        popupMenu.show(); 
       } 
       popupMenu.show(); 
      } 
     }); 
     lblListheader.setText(headerTitle); 
     return convertView; 
    } 

    private void AdminSelectDealer(int position) { 
     final App editor = (App) App.getInstance(); 
     editor.setCurrentParentId(dealerData.get(position).getId()); 
     editor.setCurrentParentType(dealerData.get(position).getUsetype()); 
     editor.setCurrentParentName(dealerData.get(position).getName()); 
     editor.setCurrentParentMstrLock(dealerData.get(position).getMstrlock()); 
     editor.setCurrentParentCommision(dealerData.get(position).getCommission()); 
     editor.setCurrentParentLockbtng(dealerData.get(position).getLgnusrlckbtng()); 
     editor.setCurrentParentCloseAc(dealerData.get(position).getLgnusrCloseAc()); 
     editor.setCurrentParentMastrName(dealerData.get(position).getMstrname()); 
     editor.setCurrentParentPartner(dealerData.get(position).getPartner()); 
     editor.setCurrentParentrMaxStake(dealerData.get(position).getLgnUserMaxStake()); 
     editor.setCurrentParentMaxProfit(dealerData.get(position).getLgnUserMaxProfit()); 
     editor.setCurrentParentMaxLoss(dealerData.get(position).getLgnUserMaxLoss()); 
     editor.setCurrentParentSessionCommision(dealerData.get(position).getSessionComm()); 
     editor.setCurrentParentOtherCommision(dealerData.get(position).getOtherComm()); 
     /*editor.setCurrentParentAdminPrtner(dealerData.get(position).part()); 
     editor.setCurrentParentMasterPrtner(dealerData.get(position).getLgnUserMaxLoss()); 
     editor.setCurrentParentDealerPrtner(dealerData.get(position).getLgnUserMaxLoss());*/ 
     ViewDealerAccountAdminDialog.ViewPartnership(editor.getCurrentParentId()); 
    } 

    private void UnSelectChild(Activity activity) { 
     final App editor = (App) activity.getApplicationContext(); 
     editor.setCurrentChildId(null); 
     editor.setCurrentChildType("null"); 
     editor.setCurrentChildName(null); 
     editor.setCurrentChildMstrLock(null); 
     editor.setCurrentChildCommision(null); 
     editor.setCurrentChildLockbtng(null); 
     editor.setCurrentChildCloseAc(null); 
     editor.setCurrentChildMastrName(null); 
     editor.setCurrentChildPartner(null); 
     editor.setCurrentChildMaxStake(null); 
     editor.setCurrentChildMaxProfit(null); 
     editor.setCurrentChildMaxLoss(null); 
    } 

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

    @Override 
    public boolean isChildSelectable(int groupPosition, int childPosition) { 
     return true; 
    } 
} 
関連する問題