Android View zu View hinzufügen

Massta

Mitglied
Hallo,
ich bin neu beim Thema Android, und ich frage mich, wie ich ein View zu einem View hinzufügen kann.
Konkret habe ich eine Klasse
Java:
extends View
, der ich gerne einen Knopf hinzufügen möchte. Die Klasse lädt auch schön, da zeichnet sich auch was mit onDraw(), der OnTouchListener geht auch, nur finde ich einfach nicht heraus, wie man da jetzt noch was draufpacken kann! Kann mir irgendjemand was dazu sagen? Mir fehlt die Methode add() aus awt und swing! :(
 

Massta

Mitglied
ViewGroup hab ich mir auch schon angeguckt, hat das denn die gleichen Funktionen wie ein View? Bzw. kann man mit einer Unterklasse davon die gleichen Sachen anfangen? Und kann man das genau so schachteln wie die graphischen Objekte aus dem "richtigen" Java?
 

schlingel

Gesperrter Benutzer
Eine ViewGroup ist eine View. Also du kannst daher schon mal mit einer ViewGroup machen was du mit einer View auch kannst.

Zusätzlich kannst du auch ViewGroups in ViewGroups schachteln. Sollte man aber so gut wie möglich vermeiden. Frisst nur performance. Geht natürlich nicht immer und überall aber prinzipiell ist die Faustregel umso mehr Views umso langsamer.
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
E Android View zur Laufzeit hinzufügen Android & Cross-Platform Mobile Apps 4
R Android Zugriff auf view von MainActivity Android & Cross-Platform Mobile Apps 7
W Zur Laufzeit erstelltes MenuItem an eine View binden Android & Cross-Platform Mobile Apps 1
W Bild aus dem Internet in View bzw. ImageView laden (Fragment) Android & Cross-Platform Mobile Apps 2
J View Breite/Höhe bestimmen Android & Cross-Platform Mobile Apps 4
B Android In einem View der ersten Activity zweite anzeigen Android & Cross-Platform Mobile Apps 2
S Dynamische EditText View eingaben in Datenbank speichern Android & Cross-Platform Mobile Apps 0
V PopUp in gleicher View anzeigen Android & Cross-Platform Mobile Apps 1
M Android Suche Activity/View Namen Android & Cross-Platform Mobile Apps 1
R Android Warum (View view)? Android & Cross-Platform Mobile Apps 4
J Android neue View mit OnTouchListener Android & Cross-Platform Mobile Apps 0
B Eigene View xml-Layout einbinden Android & Cross-Platform Mobile Apps 1
R Problem mit View in ScrollView Android & Cross-Platform Mobile Apps 6
R Android Android.view Serializable ? Android & Cross-Platform Mobile Apps 3
M Activity wechseln aus List View mit Android & Cross-Platform Mobile Apps 2
M Suche Name von View Komponente Android & Cross-Platform Mobile Apps 10
G canvas in view anzeigen Android & Cross-Platform Mobile Apps 10
G Fehlermeldung: "No XML content. Please add a root view or layout to your documet." Android & Cross-Platform Mobile Apps 7
N neuen view öffnen Android & Cross-Platform Mobile Apps 13
J id's von view komponenten werden nicht gefunden Android & Cross-Platform Mobile Apps 2
C Panel/View für Android Android & Cross-Platform Mobile Apps 3
tfa Android Layout-Probleme: View programmatisch erweitern (addContentView) Android & Cross-Platform Mobile Apps 7
G Dynamische View Inhalt -> Lagesensor Android & Cross-Platform Mobile Apps 3
D Samsung Tastatur Shortcut hinzufügen Android & Cross-Platform Mobile Apps 4
W Android Wieso kann ich keine ListView mehr zum Layout hinzufügen? Android & Cross-Platform Mobile Apps 1
ruutaiokwu Android Wo das 'android.useAndroidX' property hinzufügen? Android & Cross-Platform Mobile Apps 8
B Android SQLite Tabelle neue Spalten hinzufügen Android & Cross-Platform Mobile Apps 8
J Android Java Packet in Android Java ide hinzufügen. Android & Cross-Platform Mobile Apps 3
V Buttons bei Klick hinzufügen Android & Cross-Platform Mobile Apps 2
V Buttons zur Actionbar hinzufügen Android & Cross-Platform Mobile Apps 4
J Android Verhalten beim Hinzufügen neuer Views? Android & Cross-Platform Mobile Apps 6

Ähnliche Java Themen

Neue Themen


Oben