android - fill listView frequently in a layout -
i creating layout shows database values.but error appears in logcat:
your content must have listview id attribute 'android.r.id.list'
this listactivity:
import android.app.listactivity; import android.database.cursor; import android.os.bundle; import android.util.log; import android.view.view; import android.widget.simplecursoradapter; import android.widget.simplecursoradapter.viewbinder; import android.widget.textview; public class row_user extends listactivity { private static string tag = "row_user"; static final string[] = { data.c_user, data.c_pass }; static final int[] = { r.id.row_user, r.id.row_pass }; cursor cursor; simplecursoradapter adapter; @override protected void oncreate(bundle savedinstancestate) { log.d(tag, "oncreate-------start"); super.oncreate(savedinstancestate); setcontentview(r.layout.row_users); make_and_fill_rows(); log.d(tag, "oncreate-------end"); } static final viewbinder view_binder = new viewbinder() { public boolean setviewvalue( view view, cursor cursor, int columnindex) { log.d( tag, "entering switch-case..."); switch (view .getid()) { case r.id.row_user: ((textview) view) .settext("userrrrrr"); return true; case r.id.row_pass: ((textview) view) .settext("passssssss"); return true; default: return false; } } }; private void make_and_fill_rows() { log.d(tag, "make_and_fill_rows-----start"); cursor = ((constant) getapplication()).data.query("1=1", null); adapter = new simplecursoradapter( this, r.layout.row_users, cursor, from, to); adapter.setviewbinder(view_binder); settitle("کاربران"); setlistadapter(adapter); log.d(tag, "make_and_fill_rows-----end"); } }
this layout xml:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentleft="true" > <textview android:id="@+id/row_user" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="20dp" android:layout_margintop="20dp" android:text="user" /> <textview android:id="@+id/row_pass" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="22dp" android:text="pass" /> <listview android:id="@+id/list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" > </listview> </linearlayout>
i have button in layout, starts activity in onclicklistener. can me please?
replace line
android:id="@+id/list"
with this
android:id="@android:id/list"
the exception getting
your content must have listview id attribute 'android.r.id.list'
its saying must have define listview
existed resource id android.r.id.list
can using @android:id/list
Comments
Post a Comment