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 に答える