java - ListView in TabHost -
i'm trying put listview (existing list named siteslist) in tabhost when run app, closes (without code tabhost app works), here code:
public class mainactivity extends tabactivity { private sitesadapter madapter; private listview siteslist; private static final string noutati = "noutati"; private static final string favorite = "favorite"; private static final string profile_spec = "profile"; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); log.i("stacksites", "oncreate()"); setcontentview(r.layout.activity_main); tabhost tabhost = gettabhost(); tabspec inboxspec = tabhost.newtabspec(noutati); intent inboxintent = new intent(this, noutati.class); inboxspec.setcontent(inboxintent); tabspec outboxspec = tabhost.newtabspec(favorite); //intent outboxintent = new intent(this, outboxactivity.class); //outboxspec.setcontent(outboxintent); tabhost.addtab(inboxspec); tabhost.addtab(outboxspec); siteslist = (listview)findviewbyid(r.id.siteslist); ... public class noutati extends listactivity { private listview siteslist; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.noutati); siteslist = (listview)findviewbyid(r.id.siteslist); this.setlistadapter((android.widget.listadapter) siteslist); } }
activity_main
<tabhost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <linearlayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <tabwidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <framelayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </linearlayout>
noutati.xml
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <listview android:id="@+id/siteslist" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </linearlayout>
thank much
edit: see have named variable noutati , class noutati. thy changing variable noutatiname.
as have never encountered before, i'm not sure work, error appears because have set indicator each tab spec.
so after tabspec inboxspec = tabhost.newtabspec(noutati);
should type inboxspec .setindicator("notuati");
hope helps!
also should after tabspec outboxspec = tabhost.newtabspec(favorite);
Comments
Post a Comment