1

在我的 Android 应用程序中,我有 4 个 EditText,用户在其中放置他的信息

而且我想创建另一个 EditText,其中 4 EditText 中的所有信息都被连接起来......但我真的不想这样做......

这是我的代码:

private Editable mtext1 = null;
private Editable mtext2 = null;
private Editable mtext3 = null;
private Editable mtext4 = null;

EditText mtext5;

PendingIntent mNfcPendingIntent;
IntentFilter[] mWriteTagFilters;
IntentFilter[] mNdefExchangeFilters;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mNfcAdapter = NfcAdapter.getDefaultAdapter(this);

    setContentView(R.layout.main);

    findViewById(R.id.write_tag).setOnClickListener(mTagWriter);

    //final Button quitBut = (Button) findViewById(R.id.button1);


    mNoteBarCode = ((EditText) findViewById(R.id.noteBareCode));
    mNoteAirport = ((EditText) findViewById(R.id.noteAirport));
    mNoteFlightNumber = ((EditText) findViewById(R.id.noteFlightNumber));
    mNoteName = ((EditText) findViewById(R.id.noteName));
    mNote = ((EditText) findViewById(R.id.noteFull));

    mtext1 = mNoteBarCode.getText();
    mtext2 = mNoteAirport.getText();
    mtext3 = mNoteFlightNumber.getText();
    mtext4 = mNoteName.getText();
    mtext5 = (EditText) mtext1 + (EditText) mtext2 + .......; // doesn't work
    mtext5 = (EditText) mNote.getText();
4

1 回答 1

0
String firstString = firstET.getText().toString();   // get string from first EditText
String  secondString = secondET.getText().toString();  // get string from second EditText
EditText concatenatedET = (EditText) findViewById(R.id.your_edittext);  //declare EditText you want them put in together
concatentatedET.setText(firstString + secondString);  // put the string values in

让我知道这是否适合您,或者您是否需要更好的解释

于 2013-03-29T16:46:01.170 回答