0

AlertDialogで連絡先を表示する際に問題が発生しましたが、私は という問題が見つかりましたが、まだ混乱していると思います。私のコードの関連容疑者の部分は次のとおりです。SimpleCursorAdapterにはどのような種類のXMLが必要ですか?

SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, 
     android.R.layout.simple_list_item_1, mContacts, 
     new String[] { ContactsContract.Contacts.DISPLAY_NAME }, 
     new int[] { android.R.id.text1 }); 

...今、「simple_list_item_1は」しかし 私はそれ爆弾、このListActivityを実行しようとすると、コンパイラ(エミュレータでアプリを実行)によって受け入れられています。

このタスクを達成する方法について他の場所を読んだら、私の目は先に明るく照らされた "simple_list_item_1" - それはどこにありますか?私はsimple_list_item_1.xmlファイルを作成せず、\ res \ layoutフォルダにも存在しません。だから私(Eclipseで)は "simple_list_item_1"を右クリックして "Open Declaration"を選択し、 "Class File Editor | Source nout found | JARファイル"について、Debug Perspectiveに表示されているものとほとんど同じようにエラーメッセージを呼び出しました。 ... \ android.jarにソース添付ファイルがありません。 "

これは問題だとします(私の\ res \ layoutフォルダには "simple_list_item_1.xml"はありません)。このファイルには正確に何が期待されていますか?各連絡先を表示する)ここで

==============

は、いくつかのLogCatデータである:ここで

はLogCatの最後の行があり、それが到達したら(それが死ぬようだ/ハングListActivity(ContactsActivity):。

com.aXX3AndSpace.KeepInTouch/.KeepInTouchActivity: +5s368ms 
01-08 21:54:34.020: I/ActivityManager(61): Starting: Intent { cmp=com.aXX3AndSpace.KeepInTouch/.ContactsActivity } from pid 385 

...と、ここでは1つの未遂の実行中にエラーのMSGのすべてに注意してください(オープンアプリは、ListActivityを起動しようとする)でMSGを「これが発生することはありません」です最後:

01-08 21:53:36.592: E/Zygote(33): setreuid() failed. errno: 2 
01-08 21:53:46.423: E/Zygote(33): setreuid() failed. errno: 17 
01-08 21:53:47.842: E/BatteryService(61): usbOnlinePath not found 
01-08 21:53:47.842: E/BatteryService(61): batteryVoltagePath not found 
01-08 21:53:47.842: E/BatteryService(61): batteryTemperaturePath not found 
01-08 21:53:47.862: E/SurfaceFlinger(61): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake 
01-08 21:53:48.082: E/SensorService(61): couldn't open device for module sensors (Invalid argument) 
01-08 21:53:53.722: E/System(61): Failure starting core service 
01-08 21:53:53.722: E/System(61): java.lang.SecurityException 
01-08 21:53:53.722: E/System(61): at android.os.BinderProxy.transact(Native Method) 
01-08 21:53:53.722: E/System(61): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146) 
01-08 21:53:53.722: E/System(61): at android.os.ServiceManager.addService(ServiceManager.java:72) 
01-08 21:53:53.722: E/System(61): at com.android.server.ServerThread.run(SystemServer.java:207) 
01-08 21:53:53.742: E/EventHub(61): could not get driver version for /dev/input/mouse0, Not a typewriter 
01-08 21:53:53.742: E/EventHub(61): could not get driver version for /dev/input/mice, Not a typewriter 
01-08 21:53:54.032: E/SoundPool(61): error loading /system/media/audio/ui/Effect_Tick.ogg 
01-08 21:53:54.032: E/SoundPool(61): error loading /system/media/audio/ui/KeypressStandard.ogg 
01-08 21:53:54.032: E/SoundPool(61): error loading /system/media/audio/ui/KeypressSpacebar.ogg 
01-08 21:53:54.042: E/SoundPool(61): error loading /system/media/audio/ui/KeypressDelete.ogg 
01-08 21:53:54.042: E/SoundPool(61): error loading /system/media/audio/ui/KeypressReturn.ogg 
01-08 21:53:54.703: E/ThrottleService(61): Could not open GPS configuration file /etc/gps.conf 
01-08 21:53:57.172: E/logwrapper(158): executing /system/bin/tc failed: No such file or directory 
01-08 21:53:57.242: E/logwrapper(159): executing /system/bin/tc failed: No such file or directory 
01-08 21:53:57.282: E/logwrapper(160): executing /system/bin/tc failed: No such file or directory 
01-08 21:54:00.074: E/jdwp(174): Failed sending reply to debugger: Broken pipe 
01-08 21:54:00.712: E/Database(116): sqlite_config failed error_code = 21. THIS SHOULD NEVER occur. 
+0

エラーが発生する可能性がありますか?それは存在する?クラッシュログを投稿してください – nandeesh

+0

クラッシュログを保存するには? [ 文字列:はい、私は_id列をアクセスしていますが –

+0

...私は「保存選択した行」オプションを参照してください、しかし確実にそこに一度にすべてを保存する方法は、(すべて選択)ですが、私はそれを見ることはありません】投影=新しいString [] {ContactsContract.Contacts._ID、 ContactsContract.Contacts.DISPLAY_NAME}。 ... int selectedId = mContacts。getInt(0); // _ID列 ... 連絡先.Data.CONTACT_ID + "=" + selectedId、null、null); ... Contract.Data.CONTACT_ID + "=" + selectedId、null、null); ... Contract.Data.CONTACT_ID + "=" + selectedId、null、null); –

答えて

2

simple_list_item_1は、SDKで定義された標準レイアウトで、それは基本的にidを持つだけのTextViewだ「アンドロイド:ID /テキスト1」、あなたはあなたのビュー識別子に供給するものです。

あなたがクラッシュのスタックトレースを持っていますか?これは、simple_list_item_1レイアウトが欠落している可能性が最も高いためです。

+0

「選択した項目をテキストファイルにエクスポート」を選択すると、(LogCatから)何もエクスポートされません。 「すべて選択」するにはどうすればいいですか? –

+0

"ぎこちない"かなりのビットはここにあります:http://stackoverflow.com/questions/8767184/listactivity-starts-but-then-fails-almost-immediately –

1

Eclipseウィザードを使用して新しいXMLレイアウトファイルを作成します。 、このレイアウトで

TextView(またはその他の容器)の要素を作成し、text1それを呼び出す:このファイルの名前は、コード内simple_list_item_1を置き換えます

その後SimpleCursorAdaptorは、あなたの連絡先情報やtext1フィールドと一致しますカーソルの投影が_ID列が含まれていない場合、あなたのレイアウトで

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 
<TextView 
    android:id="@+id/text1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="TextView" /> 

+0

あなたの問題を解決するのに役立ちましたか? – znat

関連する問題