Hallo, ich bin neu bei Android und es gibt ein Projekt, das ich mache, wo ich mehrere EditText
haben, die ich in konvertieren möchte. Ich benötige eine Methode, um mir alle von ihnen durch den Klick auf eine SchaltflächeÄndern von 2 oder mehr edittexts zu textview android
Haupttätigkeit
public class MainActivity extends AppCompatActivity {
EditText[] editTextArray = new EditText[]{
(EditText) findViewById(R.id.editText),
(EditText) findViewById(R.id.editText3),
(EditText) findViewById(R.id.editText4),
(EditText) findViewById(R.id.editText5),
(EditText) findViewById(R.id.editText6),
(EditText) findViewById(R.id.editText7),
(EditText) findViewById(R.id.editText8),
(EditText) findViewById(R.id.editText9),
(EditText) findViewById(R.id.editText10),
(EditText) findViewById(R.id.editText11),
(EditText) findViewById(R.id.editText12),
(EditText) findViewById(R.id.editText13),
(EditText) findViewById(R.id.editText14),
(EditText) findViewById(R.id.editText15),
(EditText) findViewById(R.id.editText16),
(EditText) findViewById(R.id.editText17),
(EditText) findViewById(R.id.editText18),
};
TextView[] textViews = new TextView[]
{
(TextView) findViewById(R.id.textView15),
(TextView) findViewById(R.id.textView20),
(TextView) findViewById(R.id.textView21),
(TextView) findViewById(R.id.textView22),
(TextView) findViewById(R.id.textView23),
(TextView) findViewById(R.id.textView24),
(TextView) findViewById(R.id.textView26),
(TextView) findViewById(R.id.textView27),
(TextView) findViewById(R.id.textView28),
(TextView) findViewById(R.id.textView29),
(TextView) findViewById(R.id.textView30),
(TextView) findViewById(R.id.textView31),
(TextView) findViewById(R.id.textView32),
(TextView) findViewById(R.id.textView33),
(TextView) findViewById(R.id.textView34),
(TextView) findViewById(R.id.textView35),
(TextView) findViewById(R.id.textView36),
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
for (int x = 0; x < editTextArray.length; x++) {
editTextArray[x].setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String output = x.getText().toString();
textViews.setText(output);
}
});
}
}
}
können Sie dynamische Textview erstellen ... warum Sie editText in Textview –
Warum Sie konvertieren EditText zu Textview müssen konvertieren Bitte Textview dynamisch Keine Umwandlung erforderlich hinzufügen. –