gpt4 book ai didi

android - ClassCastException android.view.viewgroup.$layoutParams

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:44:08 24 4
gpt4 key购买 nike

 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com