Note that there are some explanatory texts on larger screens.

plurals
  1. POListView is not populating
    primarykey
    data
    text
    <p>I created an Adapter to populate my custom listView and when ran on the emulator the activity is blank. Plz help. I am sure I'm missing something 'cause I am new to java &amp; Android. Some code snippets to correct it and pointers will be appreciated. Thnx!</p> <p>My Activity:</p> <pre><code>public class List_AC3 extends ListActivity { /** * -- Called when the activity is first created * =================================================================== */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.list_view2); displayResultList(); } private void displayResultList() { Cursor databaseCursor = null; DomainAdapter databaseListAdapter = new DomainAdapter(this, R.layout.list_item, databaseCursor, new String[] {"label", "title", "description"}, new int[] { R.id.label, R.id.listTitle, R.id.caption }); databaseListAdapter.notifyDataSetChanged(); setListAdapter(databaseListAdapter); } } </code></pre> <p>My Adapter:</p> <pre><code>public class DomainAdapter extends SimpleCursorAdapter{ private LayoutInflater mInflater; String extStorageDirectory; public DomainAdapter(Context context, int layout, Cursor c, String[] from, int[] to) { super(context, layout, c, from, to); mInflater = LayoutInflater.from(context); } public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.list_item, null); holder = new ViewHolder(); holder.text1 = (TextView) convertView.findViewById(R.id.label); holder.text2 = (TextView) convertView.findViewById(R.id.listTitle); holder.text3 = (TextView) convertView.findViewById(R.id.caption); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } extStorageDirectory = Environment.getExternalStorageDirectory().toString(); File dbfile = new File(extStorageDirectory+ "/Aero-Technologies/flyDroid/dB/flyDroid.db"); SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null); Cursor data = db.rawQuery("SELECT * FROM AC_list", null); data.moveToPosition(position); int label_index = data.getColumnIndex("label"); String label = data.getString(label_index); int title_index = data.getColumnIndex("title"); String title = data.getString(title_index); int description_index = data.getColumnIndex("description"); String description = data.getString(description_index); holder.text1.setText(label); holder.text2.setText(title); holder.text3.setText(description); return convertView; } static class ViewHolder { TextView text1; TextView text2; TextView text3; } } </code></pre> <p>The list_view2.xml:</p> <pre><code> &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;RelativeLayout android:layout_width="fill_parent" android:layout_height="30dip" android:padding="4dip" android:background="@drawable/gradient" &gt; &lt;ImageButton android:id="@+id/homeBtn" android:src="@drawable/ic_menu_icon" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:background="@null" /&gt; &lt;TextView android:id="@+id/titleBarTitle" android:layout_centerInParent="true" android:layout_width="wrap_content" android:layout_height="match_parent" android:textSize="18sp" /&gt; &lt;ImageButton android:id="@+id/toolBtn" android:src="@drawable/ic_menu_list" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignParentRight="true" android:background="@null" /&gt; &lt;/RelativeLayout&gt; &lt;ListView android:id="@id/android:list" android:layout_height="wrap_content" android:layout_width="fill_parent" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>And my list_item.xml:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/acItem" style="@style/listItem" &gt; &lt;TextView android:id="@+id/label" style="@style/listAcronym" /&gt; &lt;TextView android:id="@+id/listTitle" style="@style/listTitle" /&gt; &lt;TextView android:id="@+id/caption" style="@style/listDiscription"/&gt; &lt;ImageView style="@style/listNextIcon" /&gt; &lt;/RelativeLayout&gt; </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