0

我做了一个程序,在我的程序中,我有一个editText. 我怎样才能获得我的价值edittext......请帮助我,我无法获得excellent.getText().toString();

有没有办法获得我的编辑文本的价值?帮助我请提前谢谢你..

这是我的代码..

TableLayout table = new TableLayout(getApplicationContext());
    table.setVerticalScrollBarEnabled(true);
    table.setPadding(10, 10, 10, 10);

    TableRow tableRow = new TableRow(getApplicationContext());
    TextView txt = new TextView(getApplicationContext());
    tableRow.addView(txt);
    tableRow.setBackgroundColor(Color.GRAY);
    txt.setText("Excellent  ");
    table.addView(tableRow);

    int j = 0;
    for (j = 1; j <= count; j++) {

        TableRow tableRow2 = new TableRow(getApplicationContext());

        EditText excellent = new EditText(getApplicationContext());
        tableRow2.addView(excellent);
    }

    TableRow tableRow1 = new TableRow(getApplicationContext());

    Button showtable = new Button(getApplicationContext());
    tableRow1.addView(showtable);
    showtable.setText("Show Table");
    showtable.setTextSize(8);

    showtable.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            excellent.getText().toString();// i cant get the value of
                                            // excellent here!
        }

    });
4

2 回答 2

0

在方法之外创建出色的参考。

TableLayout table = new TableLayout(getApplicationContext());
        table.setVerticalScrollBarEnabled(true);
        table.setPadding(10, 10, 10, 10);

EditText excellent;

    TableRow tableRow = new TableRow (getApplicationContext());             
    TextView txt = new TextView (getApplicationContext());
    tableRow.addView(txt);
    tableRow.setBackgroundColor(Color.GRAY);
    txt.setText("Excellent  ");
    table.addView(tableRow);

int j=0;
        for(j = 1; j<=count; j++){


            TableRow tableRow2 = new TableRow (getApplicationContext());                



            excelent = new EditText (getApplicationContext());
                  tableRow2.addView(excellent);
   }



        TableRow tableRow1 = new TableRow (getApplicationContext());

        Button showtable = new Button(getApplicationContext());
        tableRow1.addView(showtable);
        showtable.setText("Show Table");
        showtable.setTextSize(8);


        showtable.setOnClickListener(new OnClickListener(){

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                   excellent.getText().toString();//i cant get the value of excellent.
          }

        });
于 2013-11-12T10:38:55.817 回答
0
TableLayout table = new TableLayout(getApplicationContext());
            table.setVerticalScrollBarEnabled(true);
            table.setPadding(10, 10, 10, 10);


          EditText excellent = new EditText (getApplicationContext());
        TableRow tableRow = new TableRow (getApplicationContext());             
        TextView txt = new TextView (getApplicationContext());
        tableRow.addView(txt);
        tableRow.setBackgroundColor(Color.GRAY);
        txt.setText("Excellent  ");
        table.addView(tableRow);

        int j=0;
        for(j = 1; j<=count; j++){
        TableRow tableRow2 = new TableRow (getApplicationContext());                
        tableRow2.addView(excellent);
         }



            TableRow tableRow1 = new TableRow (getApplicationContext());

            Button showtable = new Button(getApplicationContext());
            tableRow1.addView(showtable);
            showtable.setText("Show Table");
            showtable.setTextSize(8);


            showtable.setOnClickListener(new OnClickListener(){

                @Override
                public void onClick(View arg0) {
                    // TODO Auto-generated method stub
                       excellent.getText().toString();//i cant get the value of excellent here!
              }

            });
于 2013-11-12T10:41:33.743 回答