Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java-TextView引用了可消耗列表视图子视图中的另一个TextView_Java_Android_Textview - Fatal编程技术网

Java-TextView引用了可消耗列表视图子视图中的另一个TextView

Java-TextView引用了可消耗列表视图子视图中的另一个TextView,java,android,textview,Java,Android,Textview,我有个问题。我正在用Java/Android编程列表适配器。我重写了返回视图的方法(它是单击项的可消耗列表视图)。问题在于: 日志。我向我展示: 05-17 14:04:50.494:I/createTextView(21790):0 06 Salame 05-17 14:04:50.504:I/createTextView(21790):11 Pancetta 但TextView看起来既有: 11潘切塔 11潘切塔 看起来TextView是指上一个TextView。如何解决这个问题 @

我有个问题。我正在用Java/Android编程列表适配器。我重写了返回视图的方法(它是单击项的可消耗列表视图)。问题在于:

日志。我向我展示:

  • 05-17 14:04:50.494:I/createTextView(21790):0 06 Salame
  • 05-17 14:04:50.504:I/createTextView(21790):11 Pancetta
但TextView看起来既有:

  • 11潘切塔
  • 11潘切塔
看起来TextView是指上一个TextView。如何解决这个问题

@Override
              public View getGroupView(int groupPosition, boolean isExpanded,
                           View convertView, ViewGroup parent) {
                  Log.e("SecondLevelAdapter", "getGroupView");
                  TextView tv = new TextView(OrderFirstGridPage.this);

                   if((myArrayProductList.get(groupPosition).get(0).getFlgZlozony() == 1)) {

                       Log.i("createTextView", String.valueOf(counterProductName)+" "+myArrayProductList.get(groupPosition).get(counterProductName).toString());
                       tv.setText(myArrayProductList.get(groupPosition).get(counterProductName).toString());
                       counterProductName++;
                           }
                   tv.setPadding(22, 7, 7, 7);
                   tv.setGravity(Gravity.LEFT); 
                   tv.setTextAppearance(OrderFirstGridPage.this, R.style.TextLarge);
                   tv.setTextSize(25);

                     return tv;
              } 

我认为使用LayoutInflater将是更好的方法:

      @Override
  public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
    ViewGroup parent) {

   if (convertView == null) {

    LayoutInflater inf = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   convertView = inf.inflate(R.layout.yourLayout, null);

  }

  TextView tv = (TextView) convertView.findViewById(R.id.yourTextViewId);
   if((myArrayProductList.get(groupPosition).get(0).getFlgZlozony() == 1)) {

                   Log.i("createTextView", String.valueOf(counterProductName)+" "+myArrayProductList.get(groupPosition).get(counterProductName).toString());
                   tv.setText(myArrayProductList.get(groupPosition).get(counterProductName).toString());
                   counterProductName++;
                       }
  tv.setPadding(22, 7, 7, 7);
               tv.setGravity(Gravity.LEFT); 
               tv.setTextAppearance(OrderFirstGridPage.this, R.style.TextLarge);
               tv.setTextSize(25);

 return convertView;
}

它没有显示任何东西。TextView->tv->在引用R.id.SomeTextView时似乎为空;;当我尝试创建文本视图时,它是空白的。您放大了哪个布局?你有没有扩大你的团队布局?