TextView txt=new TextView(productlist.this);
txt.setText(author.get(groupPosition));
TextView txt1=new TextView(productlist.this);
txt1.setText(price.get(groupPosition));
txt.setLayoutParams(new LayoutParams(70, LayoutParams.WRAP_CONTENT));
txt1.setLayoutParams(new LayoutParams(70,LayoutParams.WRAP_CONTENT));
LinearLayout ll=new LinearLayout(productlist.this);
ll.setOrientation(LinearLayout.HORIZONTAL);
ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
// ll.setGravity(Gravity.CENTER);
ll.addView(txt);
ll.addView(txt1);
return ll;
您好,这是可扩展 ListView
中组 View 的代码 fragment ,它给出了错误:
java.lang.ClassCastException android.view.viewgroup.$layoutParam
最佳答案
确保导入正确的 LayoutParams
。
- android.widget.LinearLayout.LayoutParams 用于 LinearLayout
- android.view.ViewGroup.LayoutParams 用于 TextView
关于android - ClassCastException android.view.viewgroup.$layoutParams,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7547957/