Problem mit View in ScrollView

Robokopp

Bekanntes Mitglied
Ich hab eine scrollbare Liste, die nicht auf einem ListView basiert, sondern auf einem langgezogenen custom View, welches sich in einem ScrollView befindet.

Nun hab ich folgendes Problem:

Ich muss innerhalb des Customviews Mauspositionen verarbeiten. Da man immer nur einen Ausschnitt des Views sieht, müsste ich irgendwie herausfinden, um wieviel gescrollt wurde.

Wie komme ich nun von dem View aus an das Parent View, um dort die Position abzufragen?
 

Robokopp

Bekanntes Mitglied
Ja das funzt leider nicht.

Möglicherweise liegt es daran, dass noch ein LinearLayout dazwischen liegt, aber ich komm mit getParent().getParent() auch nicht dran
 

schlingel

Gesperrter Benutzer
Immer schildern was man probiert hat, warum die Ideen verworfen wurden bzw. was nicht ging. Was geht nicht? Kommt null zurück oder ist das eine andere View?
 

Robokopp

Bekanntes Mitglied
Okay also im Endeffekt ist es ein selbstgeschriebenes Drag And Drop , was den Austausch von Objekten zwischen zwei Views ermöglicht.Im View befinden sich selbstgezeichnete Objekte. Die "Mausposition" wird mit den verfügbaren Objekten abgeglichen und das passende wird herausgepickt.

Das ganze hab ich auf dem PC zur Reife gebracht und dann versucht auf Android zu bringen. Das mit dem ScrollView hatte ich leider überhaupt nicht durchdacht und da steh ich nun.

Ich wollte eigentlich erst über das View die Position ermitteln, aber dann ist mir klar geworden dass es überhaupt nicht wissen kann, ob es verschoben wurde, über das Display hinaus ragt etc, da es ja lose im ScrollView liegt.

Was ich jetzt gemacht habe war das hier:


ScrollView scrollView=(ScrollView)this.getParent().getParent()
und "" "" =(ScrollView)this.getParent()

Das Problem ist halt, dass wiegesagt noch ein LinearLayout unvermeidbarerweise dazwischen liegt und ich also zwei Ebenen höher müsste.

Die Exception ist eine klassische Nullpointer
 

schlingel

Gesperrter Benutzer
Hast du noch die alten 2.* Geräte als Ziel oder warum verwendest du nicht die fertige Lösung?

Wie sieht denn der Code innerhalb der CustomView aus? Kann es sein, dass hier die parent-View nicht gesetzt wird? => Problem mit fehlendem Constructor-Aufruf
 

Robokopp

Bekanntes Mitglied
Weil das eigentliche View in dem sich das Spiel befindet auch keine Liste oder ein Grid ist und ich dort auch alles selbst zeichne, und dann dachte ich mir ich machs komplett selber

Ne die wird sicher initiiert.Vlt werd ich doch einfach ne fertige Liste nehmen
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
W Prüfen, ob App auf Gerät installiert ist Problem S10 Android & Cross-Platform Mobile Apps 11
W In App Purchase Problem? Android & Cross-Platform Mobile Apps 36
W Problem mit Android Studio Android & Cross-Platform Mobile Apps 0
T Android R.string.test+i Problem Android & Cross-Platform Mobile Apps 2
K Android to Pi | Websocket Problem Android & Cross-Platform Mobile Apps 3
N Intent und finish() Problem Android & Cross-Platform Mobile Apps 5
B Android App Programmierung Einsteiger Problem Android & Cross-Platform Mobile Apps 4
emeraldo Android Problem mit Bottomnavmenu Android & Cross-Platform Mobile Apps 10
I Das Problem mit der Tastatur... android:windowSoftInputMode="adjustPan" Android & Cross-Platform Mobile Apps 1
M Android App → Problem mit dem Speichern von einem Bitmap–Objekt. Android & Cross-Platform Mobile Apps 1
A Android Android Studio Emulator Problem Android & Cross-Platform Mobile Apps 1
S Android Studio Bluetooth App Problem Android & Cross-Platform Mobile Apps 6
J TicTacToe Problem bei kontrolle Android & Cross-Platform Mobile Apps 7
J Button array ID Problem Android & Cross-Platform Mobile Apps 2
M Problem bei Werteübergabe, MSQL verbindung Android & Cross-Platform Mobile Apps 3
S Android Problem mit Android Virtual Device erstellung. Android & Cross-Platform Mobile Apps 2
Anfänger2011 Text to Speech Problem Android & Cross-Platform Mobile Apps 1
S Android Android java onclick listener Problem Android & Cross-Platform Mobile Apps 9
A Android Problem mit ListView und OnItemClickListener.. Android & Cross-Platform Mobile Apps 10
K Problem mit arraylist und button Android & Cross-Platform Mobile Apps 16
R W-Lan Problem über Sockets Android & Cross-Platform Mobile Apps 1
P ViewPager Problem Android & Cross-Platform Mobile Apps 1
A Android Problem mit Video von Youtube abspielen Android & Cross-Platform Mobile Apps 4
A Android Problem mit Zurücktaste und ausgabe der Aktuellen Seite Android & Cross-Platform Mobile Apps 6
B Android Problem mit Soundwiedergabe Android & Cross-Platform Mobile Apps 2
T Android Android Sensor: Java Problem Android & Cross-Platform Mobile Apps 1
G Problem beim Rendern von 3D-Objekt Android & Cross-Platform Mobile Apps 0
L Android Gyroscope Sensor Problem Android & Cross-Platform Mobile Apps 2
S Android GPS Problem Android & Cross-Platform Mobile Apps 24
J Eclipse Emulator Problem Android & Cross-Platform Mobile Apps 1
J Eclipse Emulator Problem Android & Cross-Platform Mobile Apps 0
B Android Problem mit Rückgabewert Android & Cross-Platform Mobile Apps 13
L Android komisches Bitmap-Größe-Problem Android & Cross-Platform Mobile Apps 8
D Android Layout Problem Android & Cross-Platform Mobile Apps 2
R Eclipse + AndroidSDK - Problem mit Referenzen Android & Cross-Platform Mobile Apps 6
M Problem mit setOnClickListener Android & Cross-Platform Mobile Apps 4
DaniSahne96 Problem beim Appdebuggen auf Smartphone Android & Cross-Platform Mobile Apps 3
P Android Problem beim Widget - Denkfehler ? Android & Cross-Platform Mobile Apps 2
M GCM IntentService Problem Android & Cross-Platform Mobile Apps 3
D Android Gallery Problem Android & Cross-Platform Mobile Apps 5
P Problem mit Cell id Android & Cross-Platform Mobile Apps 6
L Android Problem mit "spinner" Android & Cross-Platform Mobile Apps 10
D Android problem mit geschwindigkeitsberechnung app Android & Cross-Platform Mobile Apps 2
E Android Problem mit Contact Provider Android & Cross-Platform Mobile Apps 1
H Android Problem mit ListActivity Android & Cross-Platform Mobile Apps 3
S Android Layout Problem mit fill_parent Android & Cross-Platform Mobile Apps 5
F Android ExpandableList, SimpleCursorTreeAdapter, Cursor Problem Android & Cross-Platform Mobile Apps 2
A Android Problem mit Long.getLong() bzw. Integer.getInteger() Android & Cross-Platform Mobile Apps 2
A Problem mit HTTP- Verbindung Android & Cross-Platform Mobile Apps 4
V [Java] und [JavaME] ClientServer StreamConnection . Problem beim lesen / schreiben Android & Cross-Platform Mobile Apps 2
F Eclipse JAD File erzeugen -- Problem Android & Cross-Platform Mobile Apps 10
R Ein Problem beim ausführen von folgendem Quelltext Android & Cross-Platform Mobile Apps 11
M Problem mit dem Auslesen von System Properties Android & Cross-Platform Mobile Apps 7
P wtk problem Android & Cross-Platform Mobile Apps 3
G Math exp() Problem Android & Cross-Platform Mobile Apps 4
G S40 Problem Android & Cross-Platform Mobile Apps 8
A Problem beim Subtrahieren eines Double von einem Double Android & Cross-Platform Mobile Apps 5
C Problem Device/Emulator wird nicht erkannt Android & Cross-Platform Mobile Apps 3
S Image Problem Android & Cross-Platform Mobile Apps 11
M Problem mit den Softkeys Android & Cross-Platform Mobile Apps 4
G J2ME jar-problem Android & Cross-Platform Mobile Apps 10
S Komisches Problem Android & Cross-Platform Mobile Apps 3
F Problem beim Erstellen der Jar File Android & Cross-Platform Mobile Apps 4
A Problem: Canvas-Grösse Motorola RAZR v3r Android & Cross-Platform Mobile Apps 8
S Problem mit Einbindung einer externer Bibliothek Android & Cross-Platform Mobile Apps 2
G Random - Problem Android & Cross-Platform Mobile Apps 5
E problem mit den resourcen Android & Cross-Platform Mobile Apps 2
O Problem mit Datagramconnection Android & Cross-Platform Mobile Apps 2
P Problem mit der Uhrzeit Android & Cross-Platform Mobile Apps 2
S Problem auf dem Handy Android & Cross-Platform Mobile Apps 3
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 Android Android.view Serializable ? Android & Cross-Platform Mobile Apps 3
M Android View zu View hinzufügen Android & Cross-Platform Mobile Apps 4
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
E Android View zur Laufzeit hinzufügen Android & Cross-Platform Mobile Apps 4
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
L Android ListView kollabiert in Scrollview Android & Cross-Platform Mobile Apps 9
T Android ScrollView Ganze Seite Scrollen Android & Cross-Platform Mobile Apps 3
G Warnung bei: RelativeLayout / ScrollView / LinearLayout Android & Cross-Platform Mobile Apps 2

Ähnliche Java Themen

Neue Themen


Oben