Note that there are some explanatory texts on larger screens.

plurals
  1. POadapter android app
    primarykey
    data
    text
    <p>I'm working on eclipse to develop an android app, I'm testing some code to see how it works but there are some errors which I try to solve them but I could't. I'm new to mobile development and I have to develop a to-do list . the problem is I'm not familiare with adapter and listView so I'm trying to understand them.</p> <p>Java Code</p> <pre><code> package com.example.test; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; public class SimpleListItem1Activity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_list_item1); ListView listView = (ListView) findViewById(R.id.mylist); ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, android.R.id.text1, values); listView.setAdapter(adapter); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.simple_list_item1, menu); return true; } ListView listView = (ListView) findViewById(R.id.mylist); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2" }; // Define a new Adapter // First parameter - Context // Second parameter - Layout for the row // Third parameter - ID of the TextView to which the data is written // Forth - the Array of data ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, android.R.id.text1, values); } </code></pre> <p>XML</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;ListView android:id="@+id/mylist" android:layout_width="match_parent" android:layout_height="wrap_content" &gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre> <p>LogCat</p> <pre><code> 03-14 14:57:07.643: E/AndroidRuntime(773): ... 11 more [2013-03-14 17:54:54 - test] ------------------------------ [2013-03-14 17:54:54 - test] Android Launch! [2013-03-14 17:54:54 - test] adb is running normally. [2013-03-14 17:54:54 - test] Performing com.example.test.SimpleListItem1Activity activity launch [2013-03-14 17:54:54 - test] Automatic Target Mode: launching new emulator with compatible AVD 'AVD_for_Nexus_S_by_Google' [2013-03-14 17:54:54 - test] Launching a new emulator with Virtual Device 'AVD_for_Nexus_S_by_Google' [2013-03-14 17:55:08 - Emulator] emulator: warning: opening audio input failed [2013-03-14 17:55:08 - Emulator] [2013-03-14 17:55:08 - test] New emulator found: emulator-5554 [2013-03-14 17:55:08 - test] Waiting for HOME ('android.process.acore') to be launched... [2013-03-14 17:56:06 - test] HOME is up on device 'emulator-5554' [2013-03-14 17:56:06 - test] Uploading test.apk onto device 'emulator-5554' [2013-03-14 17:56:07 - test] Installing test.apk... [2013-03-14 17:57:06 - test] Success! [2013-03-14 17:57:06 - test] Starting activity com.example.test.SimpleListItem1Activity on device emulator-5554 [2013-03-14 17:57:09 - test] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.test/.SimpleListItem1Activity } [2013-03-14 18:07:20 - test] ------------------------------ [2013-03-14 18:07:20 - test] Android Launch! [2013-03-14 18:07:20 - test] adb is running normally. [2013-03-14 18:07:20 - test] Performing com.example.test.SimpleListItem1Activity activity launch [2013-03-14 18:07:20 - test] Automatic Target Mode: launching new emulator with compatible AVD 'AVD_for_Nexus_S_by_Google' [2013-03-14 18:07:20 - test] Launching a new emulator with Virtual Device 'AVD_for_Nexus_S_by_Google' [2013-03-14 18:07:23 - Emulator] emulator: warning: opening audio input failed [2013-03-14 18:07:23 - Emulator] [2013-03-14 18:07:23 - test] New emulator found: emulator-5554 [2013-03-14 18:07:23 - test] Waiting for HOME ('android.process.acore') to be launched... [2013-03-14 18:08:21 - test] HOME is up on device 'emulator-5554' [2013-03-14 18:08:21 - test] Uploading test.apk onto device 'emulator-5554' [2013-03-14 18:08:21 - test] Installing test.apk... [2013-03-14 18:10:25 - test] Failed to install test.apk on device 'emulator-5554! [2013-03-14 18:10:25 - test] (null) [2013-03-14 18:10:25 - test] Launch canceled! </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload