Klaus
- Forum-Beiträge: 33
19.12.2013, 17:52:35 via Website
19.12.2013 17:52:35 via Website
Meine Activity-Klasse soll auf Variablen des CustomView zugreifen.
Jedoch bekomme ich beim Debuggen während des Einzelschrittdurchlaufs
in Eclipse eine "<error(s)_during_the_evaluation>"-Meldung angezeigt für
die Variable parX_loaded (und aller anderen Variablen aus dem CustomView);
ich nehme an, weil die Activity nicht auf die CustomView-Variable zugreifen kann.
Was muß ich ändern, damit ich in der Activity auf CustomView-Variablen zugreifen kann?
Activity
CustomLayout
main.xml
Jedoch bekomme ich beim Debuggen während des Einzelschrittdurchlaufs
in Eclipse eine "<error(s)_during_the_evaluation>"-Meldung angezeigt für
die Variable parX_loaded (und aller anderen Variablen aus dem CustomView);
ich nehme an, weil die Activity nicht auf die CustomView-Variable zugreifen kann.
Was muß ich ändern, damit ich in der Activity auf CustomView-Variablen zugreifen kann?
Activity
1package com.meineappactivity;
2import com.test.customview.CustomLayout;
3public class MeineActivity extends Activity
4{
5 public void onCreate(Bundle savedInstanceState) {
6 super.onCreate(savedInstanceState);
7 setContentView(R.layout.main);
8}
9
10//Methode wird von onResume und von onCreate aufgerufen
11public void load_values_from_sharedprefs()
12{
13 if (CustomLayout.parX_loaded.length>0) // <error(s)_during_the_evaluation>
14 {...}
15}
16}
2import com.test.customview.CustomLayout;
3public class MeineActivity extends Activity
4{
5 public void onCreate(Bundle savedInstanceState) {
6 super.onCreate(savedInstanceState);
7 setContentView(R.layout.main);
8}
9
10//Methode wird von onResume und von onCreate aufgerufen
11public void load_values_from_sharedprefs()
12{
13 if (CustomLayout.parX_loaded.length>0) // <error(s)_during_the_evaluation>
14 {...}
15}
16}
CustomLayout
1package com.test.customview
2import com.meineappactivity.R;
3
4public class CustomLayout extends RelativeLayout{
5public static int parX_loaded [] = new int[40];
6}
2import com.meineappactivity.R;
3
4public class CustomLayout extends RelativeLayout{
5public static int parX_loaded [] = new int[40];
6}
main.xml
1<?xml version="1.0" encoding="utf-8"?>
2<com.test.customview.CustomLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:id="@+id/custom_layout_id"
4 android:orientation="vertical"
5 android:layout_width="fill_parent"
6 android:layout_height="fill_parent"
7 >
8<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
9 android:id="@+id/layout_id"
10 android:layout_width="fill_parent"
11 android:layout_height="fill_parent"
12 >
13</RelativeLayout>
14</com.test.customview.CustomLayout>
2<com.test.customview.CustomLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:id="@+id/custom_layout_id"
4 android:orientation="vertical"
5 android:layout_width="fill_parent"
6 android:layout_height="fill_parent"
7 >
8<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
9 android:id="@+id/layout_id"
10 android:layout_width="fill_parent"
11 android:layout_height="fill_parent"
12 >
13</RelativeLayout>
14</com.test.customview.CustomLayout>
— geändert am 19.12.2013, 18:00:13
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.