Search code examples
androidtextviewandroid-4.0-ice-cream-sandwich

Why isn't grid showing text of TextView only in Android 4.0?


        // programmatically creating grid on run time
        int z=0;
        if(Integer.valueOf(sing.questionsObjectArr[index].noOfcolumns) > Integer.valueOf(
                sing.questionsObjectArr[index].noOfrows)){
            while(z < Integer.valueOf(sing.questionsObjectArr[index].noOfcolumns)){
                gridEdittext.add(new ArrayList<TextView>());
                z++;
            }
        }
        else{
            while(z < Integer.valueOf(sing.questionsObjectArr[index].noOfrows)){
                gridEdittext.add(new ArrayList<TextView>());
                z++;
            }
        }

        for(int x = 0; x < Integer.valueOf(sing.questionsObjectArr[index].noOfrows); x++){

                this.ll = new LinearLayout(this);
                this.ll.setLayoutParams(new LinearLayout.LayoutParams(
                        LinearLayout.LayoutParams.WRAP_CONTENT,
                        LinearLayout.LayoutParams.WRAP_CONTENT));
                this.ll.setOrientation(0);

            for(int y = 0; y < Integer.valueOf(sing.questionsObjectArr[index].noOfcolumns); y++){

                if(y==0){
                    this.gridEdittext.get(y).add(new TextView(this));
                    this.gridEdittext.get(y).get(x).setId(y);
                    this.gridEdittext.get(y).get(x).setTextColor(Color.BLACK);
                    if(x!=0){
                        this.gridEdittext.get(y).get(x).setText(
                                sing.questionsObjectArr[index].columnData.get(x-1).toString());
                    }
                    else{
                        this.gridEdittext.get(y).get(x).setText(
                                sing.questionsObjectArr[index].rowData.get(x).toString());
                    }
                    LinearLayout.LayoutParams colparams = new LinearLayout.LayoutParams(60, 60);
                    colparams.setMargins(20, 0, 20, 0);
                    this.gridEdittext.get(y).get(x).setLayoutParams(colparams);
                    this.ll.addView(this.gridEdittext.get(y).get(x));
                    y++;
                }
                if(x==0){
                    this.gridEdittext.get(y).add(new TextView(this));
                    this.gridEdittext.get(y).get(x).setTextColor(Color.BLACK);
                    this.gridEdittext.get(y).get(x).setId(y);
                    this.gridEdittext.get(y).get(x).setText(
                            sing.questionsObjectArr[index].rowData.get(y).toString());
                    LinearLayout.LayoutParams colparam = new LinearLayout.LayoutParams(60, 60);
                    colparam.setMargins(0, 0, 20, 0);
                    this.gridEdittext.get(y).get(x).setLayoutParams(colparam);
                    this.ll.addView(this.gridEdittext.get(y).get(x));
                }
                else{
                    this.gridEdittext.get(y).add(new EditText(this));
                    this.gridEdittext.get(y).get(x).setId(y);
                    this.gridEdittext.get(y).get(x).setText("");
                    this.gridEdittext.get(y).get(x).setLayoutParams(new LinearLayout.LayoutParams(80, 80));
                    this.ll.addView(this.gridEdittext.get(y).get(x));
                }
            }
            tlayout.addView(this.ll);
            tlayout.setBackgroundResource(R.drawable.roundshape);
        }

I am creating dynamic grid consist of EditText which can accept data, table is surrounded by TextView. The problem is that the text of the TextView is showing perfectly in Android 2.3, but not in Android 4.0.


Solution

  • I was using SAX parsing, it was working well but in Android 4.0 the text was not showing on label coming from internet server. Then i changed parsing technique to DOM parsing problem is resolved.