How use ListView in android Tab? -
good day. in app have 3 tab (one activity extend tabactivity , others activitys provides access content). in first tab have imageview, few textview , works. when add listview , in activity contain listview add few rows not show in may tab.
can tell me wrong? here code:
in startactivity:
intent = new intent().setclass(this, goodsandshopsactivity.class); spec = tabhost.newtabspec("shops").setindicator("shops", res.getdrawable(r.drawable.ic_tab_shops)) .setcontent(intent); tabhost.addtab(spec);
in goodsandshopsactivity:
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.descriptions); m_shopslayout = (listview) findviewbyid(r.id.shops); m_shoplist = new arraylist<shop>(); m_shopadapter = new shopadapter(m_shoplist, this); m_shopslayout.setchoicemode(listview.choice_mode_single); m_shopslayout.setadapter(m_shopadapter); (int = 0; i<3; i++) { m_shoplist.add(new shop("new description")); m_shopadapter.notifydatasetchanged(); } }
in class extends baseadapter:
@override public view getview(int position, view convertview, viewgroup parent) { viewholder holder; if (convertview == null) { convertview = m_inflater.inflate(r.layout.shop, null); holder = new viewholder(); holder.descriptions = (textview) convertview.findviewbyid(r.id.shop); convertview.settag(holder); } else { holder = (viewholder) convertview.gettag(); } string textonview = m_shops.get(position).getdescription(); holder.descriptions.settext(textonview); return convertview; } static class viewholder{ textview descriptions; }
and xml define listview (sorry much):
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <linearlayout android:id="@+id/full_info" android:layout_width="wrap_content" android:layout_height="wrap_content"> <imageview android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10px" android:src="@drawable/icon"> </imageview> <linearlayout android:id="@+id/short_info" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_torightof="@id/icon" android:layout_alignparentright="true"> <textview android:id="@+id/name_for_good" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:gravity="center_vertical" android:text="Наименование товара"> </textview> <textview android:id="@+id/best_price" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:singleline="true" android:ellipsize="marquee" android:text="Лучшая цена: "> </textview> <textview android:id="@+id/worst_price" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:text="Худшая цена: "> </textview> </linearlayout> </linearlayout> <linearlayout android:id="@+id/description_and_shop" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/full_info"> <textview android:id="@+id/description" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Большое подробное описание товара с всякими деталями, нюансами и т.п."> </textview> <scrollview android:id="@+id/scrollview" android:layout_width="fill_parent" android:layout_height="fill_parent"> <listview android:id="@+id/shops" android:layout_width="fill_parent" android:layout_height="fill_parent"> </listview> </scrollview> </linearlayout>
update: after coffe brake find mistake: in xml add in last linearlayout "orientation=vertical" , rows appeared. solved
also, remember listview
scrollable, shouldn't need put under scrollview
. im glad solved problem youself :)
Comments
Post a Comment