Problem mit ListView?!?!?

  • Antworten:10
  • OffenNicht stickyBentwortet
  • Forum-Beiträge: 21

22.08.2013 21:14:41 via Website

Hallo,
mein Problem scheint mir eigentlich simpel, aber ich habe irgendwie eine Blockade.
Ich habe einen SlideMenu integriert mit dem man von der MainActivity. aus die Seite, zB. UntersuchungActivity (fragment2 layout) öffnet.
In meine UntersuchungActivity habe ich einen String integriert, das ich per ListView in meine fragment2.xml anzeigen haben möchte.
Muss noch etwas in meine MainActivity?

Hier meine Codes:

UntersuchungActivity:

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.actionbarsherlock.app.SherlockFragment;


public class Untersuchung extends SherlockFragment {

ListView l;
String[] untersu= {"APGAR", "U1 Untersuchung", "U2 Untersuchung", "U3 Untersuchung", "U4 Untersuchung",
"U5 Untersuchung", "U6 Untersuchung", "U7 Untersuchung", "U7a Untersuchung", "U8 Untersuchung",
"U9 Untersuchung", "U10 Untersuchung", "U11 Untersuchung", "J1 Untersuchung", "J2 Untersuchung"};

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment2, container, false);

l = getListView();
ArrayAdapter<String> adapter = new ArrayAdapter<String> (getActivity(), android.R.layout.simple_list_item_1, untersu);
l = setAdapter (adapter);

return rootView;
}
private ListView setAdapter(ArrayAdapter<String> adapter) {
// TODO Auto-generated method stub
return null;
}
private ListView getListView() {
// TODO Auto-generated method stub
return null;
}
}


fragment2:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>

</RelativeLayout>

DANKE

— geändert am 22.08.2013 21:32:42

  • Forum-Beiträge: 22.351

22.08.2013 21:24:58 via App

Hallo Volkan,

Bitte nicht pushen. gib doch der Community bitte etwas Zeit - ich bin mir sicher, dass sich hier jemand melden wird, sobald er / sie eine Antwort auf deine Frage hat.

Und bitte bearbeite doch nochmal etwas deinen Threadtitel, damit andere User besser erkennen können, worum es hier geht. Hierfür einfach unter deinem ersten Beitrag auf "Bearbeiten" drücken, dann kannst du oben noch mal den Titel bearbeiten.

Viele Grüße,
Andy


OnePlus 3 (Resurrection Remix 5.8.2)
LG G Watch

Regeln | unsere Mods & Admins

  • Forum-Beiträge: 1.525

22.08.2013 21:38:55 via Website

Kannst du nicht warten?:D

Als erstes hilft dir immer deine LogCat.
Was sagt deine LogCat?


LG
  • Forum-Beiträge: 307

22.08.2013 21:56:13 via Website

Hi Volker,

versteh ich dich da richtig du möchtest aus der Klasse UntersuchungsActivity einen String an die Klasse Untersuchung übergeben?
Wo ist dann das Problem? Gib der Klasse Untersuchung einen Methode newInstance und übergib der die Werte.
Beispiel:

1static Untersuchung newInstance(String deinText) {
2
3 untersuchung f = new Untersuchung();
4
5 Bundle args = new Bundle();
6
7 args.putString("DEIN_STRING", deinText);
8
9 f.setArguments(args);
10
11 return f;
12 }

Mit der Methode getArguments() kommste dann wieder an das Bundle ran.

Haben die Funktionen getListView() und setAdapter() eigentlich einen logischen Sinn?

mfg Christian

— geändert am 22.08.2013 21:57:06

www.apps-mit-web.de

  • Forum-Beiträge: 21

22.08.2013 21:58:48 via Website

Weisst doch wies ist :bashful:

Oki meine LogCat:

08-22 15:57:01.433: D/AndroidRuntime(2179): CheckJNI is ON
08-22 15:57:01.515: D/dalvikvm(2179): Trying to load lib libjavacore.so 0x0
08-22 15:57:01.535: D/dalvikvm(2179): Added shared lib libjavacore.so 0x0
08-22 15:57:01.593: D/dalvikvm(2179): Trying to load lib libnativehelper.so 0x0
08-22 15:57:01.593: D/dalvikvm(2179): Added shared lib libnativehelper.so 0x0
08-22 15:57:01.736: E/cutils-trace(2179): Error opening trace file: No such file or directory (2)
08-22 15:57:02.785: D/AndroidRuntime(2179): Calling main entry com.android.commands.pm.Pm
08-22 15:57:02.895: W/ActivityManager(285): No content provider found for permission revoke: file:///data/local/tmp/KidsGesundheitssurvey.apk
08-22 15:57:03.025: W/ActivityManager(285): No content provider found for permission revoke: file:///data/local/tmp/KidsGesundheitssurvey.apk
08-22 15:57:03.025: I/PackageManager(285): Copying native libraries to /data/app-lib/vmdl-1963368662
08-22 15:57:03.423: D/dalvikvm(285): GC_FOR_ALLOC freed 576K, 33% free 6222K/9228K, paused 153ms, total 153ms
08-22 15:57:04.223: D/dalvikvm(285): GC_FOR_ALLOC freed 885K, 33% free 6264K/9228K, paused 156ms, total 156ms
08-22 15:57:04.793: D/dalvikvm(285): GC_FOR_ALLOC freed 927K, 32% free 6278K/9228K, paused 149ms, total 150ms
08-22 15:57:05.443: D/dalvikvm(285): GC_FOR_ALLOC freed 943K, 32% free 6282K/9228K, paused 150ms, total 150ms
08-22 15:57:05.863: I/ActivityManager(285): Force stopping package com.example.kidsgesundheitssurvey appid=10050 user=-1
08-22 15:57:05.863: I/ActivityManager(285): Killing proc 2135:com.example.kidsgesundheitssurvey/u0a10050: force stop com.example.kidsgesundheitssurvey
08-22 15:57:05.873: W/ActivityManager(285): Force removing ActivityRecord{41a32c18 u0 com.example.kidsgesundheitssurvey/.MainActivity}: app died, no saved state
08-22 15:57:05.985: W/InputDispatcher(285): channel '41a6e370 com.example.kidsgesundheitssurvey/com.example.kidsgesundheitssurvey.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
08-22 15:57:05.985: E/InputDispatcher(285): channel '41a6e370 com.example.kidsgesundheitssurvey/com.example.kidsgesundheitssurvey.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
08-22 15:57:06.024: I/WindowState(285): WIN DEATH: Window{41a6e370 u0 com.example.kidsgesundheitssurvey/com.example.kidsgesundheitssurvey.MainActivity}
08-22 15:57:06.024: W/InputDispatcher(285): Attempted to unregister already unregistered input channel '41a6e370 com.example.kidsgesundheitssurvey/com.example.kidsgesundheitssurvey.MainActivity (server)'
08-22 15:57:06.403: I/Choreographer(413): Skipped 35 frames! The application may be doing too much work on its main thread.
08-22 15:57:06.534: W/InputMethodManagerService(285): Got RemoteException sending setActive(false) notification to pid 2135 uid 10050
08-22 15:57:06.603: I/PackageManager(285): Package com.example.kidsgesundheitssurvey codePath changed from /data/app/com.example.kidsgesundheitssurvey-2.apk to /data/app/com.example.kidsgesundheitssurvey-1.apk; Retaining data and using new
08-22 15:57:07.033: I/PackageManager(285): Running dexopt on: com.example.kidsgesundheitssurvey
08-22 15:57:08.683: W/dalvikvm(2190): method Lcom/actionbarsherlock/internal/widget/IcsLinearLayout;.drawDividersHorizontal incorrectly overrides package-private method with same name in Landroid/widget/LinearLayout;
08-22 15:57:08.683: W/dalvikvm(2190): method Lcom/actionbarsherlock/internal/widget/IcsLinearLayout;.drawDividersVertical incorrectly overrides package-private method with same name in Landroid/widget/LinearLayout;
08-22 15:57:08.693: W/dalvikvm(2190): method Lcom/actionbarsherlock/internal/widget/IcsLinearLayout;.drawHorizontalDivider incorrectly overrides package-private method with same name in Landroid/widget/LinearLayout;
08-22 15:57:08.693: W/dalvikvm(2190): method Lcom/actionbarsherlock/internal/widget/IcsLinearLayout;.drawVerticalDivider incorrectly overrides package-private method with same name in Landroid/widget/LinearLayout;
08-22 15:57:10.293: D/dalvikvm(2190): DexOpt: load 648ms, verify+opt 1525ms, 1273684 bytes
08-22 15:57:10.413: W/PackageManager(285): Code path for pkg : com.example.kidsgesundheitssurvey changing from /data/app/com.example.kidsgesundheitssurvey-2.apk to /data/app/com.example.kidsgesundheitssurvey-1.apk
08-22 15:57:10.413: W/PackageManager(285): Resource path for pkg : com.example.kidsgesundheitssurvey changing from /data/app/com.example.kidsgesundheitssurvey-2.apk to /data/app/com.example.kidsgesundheitssurvey-1.apk
08-22 15:57:10.446: I/ActivityManager(285): Force stopping package com.example.kidsgesundheitssurvey appid=10050 user=-1
08-22 15:57:10.623: D/dalvikvm(285): GC_FOR_ALLOC freed 917K, 32% free 6313K/9228K, paused 148ms, total 148ms
08-22 15:57:10.933: I/ActivityManager(285): Force stopping package com.example.kidsgesundheitssurvey appid=10050 user=0
08-22 15:57:11.063: D/dalvikvm(413): GC_EXPLICIT freed 639K, 19% free 7230K/8916K, paused 5ms+14ms, total 117ms
08-22 15:57:11.193: D/dalvikvm(1877): GC_EXPLICIT freed 154K, 13% free 2837K/3248K, paused 5ms+8ms, total 98ms
08-22 15:57:11.373: I/InputReader(285): Reconfiguring input devices. changes=0x00000010
08-22 15:57:11.453: D/BackupManagerService(285): Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.example.kidsgesundheitssurvey flg=0x8000010 (has extras) }
08-22 15:57:11.503: W/ContextImpl(1894): Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1385 android.content.ContextWrapper.startService:473 android.content.ContextWrapper.startService:473 com.android.keychain.KeyChainBroadcastReceiver.onReceive:12 android.app.ActivityThread.handleReceiver:2424
08-22 15:57:11.753: I/InputReader(285): Reconfiguring input devices. changes=0x00000010
08-22 15:57:11.843: D/BackupManagerService(285): Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.kidsgesundheitssurvey flg=0x8000010 (has extras) }
08-22 15:57:11.873: V/BackupManagerService(285): removePackageParticipantsLocked: uid=10050 #1
08-22 15:57:11.933: V/BackupManagerService(285): addPackageParticipantsLocked: #1
08-22 15:57:12.023: D/dalvikvm(371): GC_FOR_ALLOC freed 297K, 12% free 2714K/3052K, paused 321ms, total 342ms
08-22 15:57:13.293: W/GCoreUlr(595): sending intent to update reporting state
08-22 15:57:13.894: I/GCoreUlr(595): Ensuring that reporting is stopped because of reasons: (no Google accounts)
08-22 15:57:13.903: D/GCoreFlp(595): Unknown pending intent to remove.
08-22 15:57:13.923: I/GCoreUlr(595): Ensuring that reporting is stopped because of reasons: (no Google accounts)
08-22 15:57:13.923: D/GCoreFlp(595): Unknown pending intent to remove.
08-22 15:57:13.933: I/GCoreUlr(595): Unbound from all location providers
08-22 15:57:13.933: I/GCoreUlr(595): Unbound from all location providers
08-22 15:57:14.723: D/dalvikvm(285): GC_EXPLICIT freed 1093K, 36% free 5942K/9228K, paused 370ms+52ms, total 1963ms
08-22 15:57:15.073: D/AndroidRuntime(2179): Shutting down VM
08-22 15:57:15.082: D/jdwp(2179): Got wake-up signal, bailing out of select
08-22 15:57:15.082: D/dalvikvm(2179): Debugger has detached; object registry had 1 entries
08-22 15:57:15.702: W/RecognitionManagerService(285): no available voice recognition services found for user 0
08-22 15:57:16.502: D/AndroidRuntime(2202): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
08-22 15:57:16.502: D/AndroidRuntime(2202): CheckJNI is ON
08-22 15:57:16.572: D/dalvikvm(2202): Trying to load lib libjavacore.so 0x0
08-22 15:57:16.602: D/dalvikvm(2202): Added shared lib libjavacore.so 0x0
08-22 15:57:16.672: D/dalvikvm(2202): Trying to load lib libnativehelper.so 0x0
08-22 15:57:16.672: D/dalvikvm(2202): Added shared lib libnativehelper.so 0x0
08-22 15:57:16.805: E/cutils-trace(2202): Error opening trace file: No such file or directory (2)
08-22 15:57:17.843: D/AndroidRuntime(2202): Calling main entry com.android.commands.am.Am
08-22 15:57:17.863: D/dalvikvm(2202): Note: class Landroid/app/ActivityManagerNative; has 163 unimplemented (abstract) methods
08-22 15:57:17.902: I/ActivityManager(285): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.kidsgesundheitssurvey/.MainActivity} from pid 2202
08-22 15:57:17.962: W/WindowManager(285): Screenshot failure taking screenshot for (328x583) to layer 21005
08-22 15:57:18.024: W/dalvikvm(2213): PR_CAPBSET_DROP 0 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.024: W/dalvikvm(2213): PR_CAPBSET_DROP 1 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.024: D/AndroidRuntime(2202): Shutting down VM
08-22 15:57:18.036: W/dalvikvm(2213): PR_CAPBSET_DROP 2 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.036: W/dalvikvm(2213): PR_CAPBSET_DROP 3 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.042: W/dalvikvm(2213): PR_CAPBSET_DROP 4 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.042: W/dalvikvm(2213): PR_CAPBSET_DROP 5 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.042: W/dalvikvm(2213): PR_CAPBSET_DROP 6 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.042: W/dalvikvm(2213): PR_CAPBSET_DROP 7 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.042: W/dalvikvm(2213): PR_CAPBSET_DROP 8 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.042: W/dalvikvm(2213): PR_CAPBSET_DROP 9 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.055: D/dalvikvm(2202): Debugger has detached; object registry had 1 entries
08-22 15:57:18.062: W/dalvikvm(2213): PR_CAPBSET_DROP 10 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.062: W/dalvikvm(2213): PR_CAPBSET_DROP 11 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.062: W/dalvikvm(2213): PR_CAPBSET_DROP 12 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.062: W/dalvikvm(2213): PR_CAPBSET_DROP 13 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.062: W/dalvikvm(2213): PR_CAPBSET_DROP 14 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 15 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 16 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 17 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 18 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 19 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 20 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 21 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 22 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 23 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 24 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 25 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 26 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 27 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 28 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 29 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 30 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 31 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 32 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: W/dalvikvm(2213): PR_CAPBSET_DROP 33 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
08-22 15:57:18.083: D/dalvikvm(2213): Not late-enabling CheckJNI (already on)
08-22 15:57:18.102: I/ActivityManager(285): Start proc com.example.kidsgesundheitssurvey for activity com.example.kidsgesundheitssurvey/.MainActivity: pid=2213 uid=10050 gids={50050, 1028}
08-22 15:57:19.142: I/Choreographer(285): Skipped 40 frames! The application may be doing too much work on its main thread.
08-22 15:57:21.543: D/dalvikvm(2213): GC_FOR_ALLOC freed 126K, 6% free 2793K/2968K, paused 47ms, total 50ms
08-22 15:57:21.563: I/dalvikvm-heap(2213): Grow heap (frag case) to 3.844MB for 1127536-byte allocation
08-22 15:57:21.693: D/dalvikvm(2213): GC_FOR_ALLOC freed 2K, 5% free 3892K/4072K, paused 123ms, total 123ms
08-22 15:57:22.543: I/Choreographer(2213): Skipped 69 frames! The application may be doing too much work on its main thread.
08-22 15:57:22.643: D/gralloc_goldfish(2213): Emulator without GPU emulation detected.
08-22 15:57:22.803: I/ActivityManager(285): Displayed com.example.kidsgesundheitssurvey/.MainActivity: +4s802ms
  • Forum-Beiträge: 21

22.08.2013 22:04:11 via Website

Hallo Christian,

ich möchte die Items im String weiter als Button nutzen.
Alles was du in meinem Code siehst habe ich aus einem Tutorial.

Danke für deine Bemühungen...
  • Forum-Beiträge: 1.525

22.08.2013 22:34:53 via Website

Und es wurde dir schon vorhin gesagt, kein push oder doppel Beiträge hinter einander.

Und Christian hat dir glaube das wichtigste gesagt.


LG

— geändert am 22.08.2013 22:37:22

  • Forum-Beiträge: 1.793

22.08.2013 23:14:01 via App

Ich verstehe Sinn und Vorhaben überhaupt nicht.
Es wird immer über eine UntersuchungsActivity geredet, aber stattdessen eine Klasse Untersuchung geliefert.
Die Methoden get/setAdapter geben beide null zurück, tun sonst nichts, werden aber benutzt, um die (ebenfalls sinnlose) Variable l zu verwenden.
Mach das doch erstmal weg/funktionierend.
Dann beschreibe bitte genauer, was du konkret mit String übergeben meinst.

LG

Liebe Grüße impjor.

Für ein gutes Miteinander: Unsere Regeln
Apps für jeden Einsatzzweck
Stellt eure App vor!

  • Forum-Beiträge: 1.793

22.08.2013 23:14:01 via App

Ich verstehe Sinn und Vorhaben überhaupt nicht.
Es wird immer über eine UntersuchungsActivity geredet, aber stattdessen eine Klasse Untersuchung geliefert.
Die Methoden get/setAdapter geben beide null zurück, tun sonst nichts, werden aber benutzt, um die (ebenfalls sinnlose) Variable l zu verwenden.
Mach das doch erstmal weg/funktionierend.
Dann beschreibe bitte genauer, was du konkret mit String übergeben meinst.

LG

Liebe Grüße impjor.

Für ein gutes Miteinander: Unsere Regeln
Apps für jeden Einsatzzweck
Stellt eure App vor!