EditText und TextView abhängig von Auswahl erzeugen

  • 5 Antworten
  • Letztes Antwortdatum
T

triac

Neues Mitglied
0
Hallo,

ich möchte im ersten Layout mittels Checkboxen die gewünschten Felder im nächsten layout definieren:

z.B.:
-Auswahl von Name / Anschrift /...
-weiter anklicken
-im layout wie zuvor ausgewählt TextView und EditText Objekte wie zuvor ausgewählt erstellen

?wie erstellt man diese Objekte in Abhängigkeit der Auswahl zuvor?

mfg Triac
 
Ich verstehe irgendwie dein Anliegen nicht, kanst du das vielleicht ein wenig genauer/anders beschreiben und/oder Beispiele geben..?
Gruß
 
ich habe 2 layouts.
Beim 1. Layout wähle ich checkboxen an.
Sobald ich auf weiter drücke kommt das nächste Layout mit EditText Feldern oder TextView Feldern wie zuvor ausgewählt.

Wenn ich also zum Beispiel das Feld Name anwähle und weiter drücke erscheint im kommenden Layout ein Feld mit der ID Name und dem Hint "Name"
 
Das kannst du doch machen wie du willst :blink:

Kannst z.B. ieiner Funktion die Felder als boolean-Wert übergeben. Oder auch iwo in einer Datei speichern oder what ever..
 
Ja schon klar, ich hab alles bis auf das per Java EditText Felder erzeugen fertig.

Wie kann ich in der Activity ein neues (vorallem nicht im Layout definiertes) EditText-Feld erzeugen? (ID, Größe, Position, etc.)
 
Hi,
versuch mal das:
Code:
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]
[LEFT]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] TesterActivity [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extends[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Activity {

LinearLayout.LayoutParams [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]layoutParams[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
LinearLayout [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]ll[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];

[/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onCreate(Bundle savedInstanceState) {
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].onCreate(savedInstanceState);
setContentView(R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]main[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
Button b = (Button) findViewById(R.id.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]Button1[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]ll[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = (LinearLayout)findViewById(R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]ausgabe[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]layoutParams[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] LinearLayout.LayoutParams
(LayoutParams.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]WRAP_CONTENT[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], LayoutParams.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]WRAP_CONTENT[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
b.setOnClickListener([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OnClickListener(){

[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onClick(View arg0) {
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// [/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#7f9fbf][SIZE=2][COLOR=#7f9fbf]TODO[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f] Auto-generated method stub[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]TextView TV = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] TextView(TesterActivity.[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
TV.setHint([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Beispiel"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]ll[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].addView(TV, [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]layoutParams[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
}

});
}[/LEFT]
[/SIZE]
Ich hoffe das ist so n etwa das, was du haben wolltest;)
Gruß
 
Zurück
Oben Unten