java.lang.IllegalAccessError:尝试访问方法android.widget.LinearLayout MainLayout=(LinearLayout)getActivity().findViewById(R.id.LinLaySub); 对于(int k=0;k
更改行java.lang.IllegalAccessError:尝试访问方法android.widget.LinearLayout MainLayout=(LinearLayout)getActivity().findViewById(R.id.LinLaySub); 对于(int k=0;k,java,android,Java,Android,更改行 MainLayout=(LinearLayout) getActivity().findViewById(R.id.LinLaySub); for(int k=0;k<Dist_cat.length;k++) { Cursor c = db.getQueryResult("select * from prod_mas where sub_name='" + Dist_catname[k] + "'"); for
MainLayout=(LinearLayout) getActivity().findViewById(R.id.LinLaySub);
for(int k=0;k<Dist_cat.length;k++) {
Cursor c = db.getQueryResult("select * from prod_mas where sub_name='" + Dist_catname[k] + "'");
for (int i = 0; i < c.getCount(); i++) {
c.moveToFirst();
ChildLayout=new LinearLayout(getActivity());
ChildLayout.setWeightSum(100);
ChildLayout.setOrientation(LinearLayout.HORIZONTAL);
ChildLayout.setBackgroundColor(getResources().getColor(R.color.sublay));
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
ChildLayout.setId(i);
edit_phy = new EditText(getActivity());
edit_phyAll.add(edit_phy);
edit_phy.setBackgroundResource(R.color.black);
edit_phy.setId(+i + 1);
edit_phy.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
ChildLayout.addView(edit_phy);
edit_trn = new EditText(getActivity());
edit_trnAll.add(edit_trn);
edit_trn.setBackgroundResource(R.color.black);
edit_trn.setId(+i + 2);
edit_trn.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
ChildLayout.addView(edit_trn);
MainLayout.onViewAdded(ChildLayout);
c.moveToNext();
}
}
至
MainLayout.onViewAdded(ChildLayout);
为什么要调用
onViewAdded()
方法?
MainLayout.addView(ChildLayout);