The ListView instance is a part of the Layout.
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
/>
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="@+id/launch"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ListView android:id="@+id/resultlist"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:footerDividersEnabled="true" >
</ListView>
<Button android:id="@+id/start"
android:text="Predict!"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
...
</FrameLayout>
</LinearLayout>
I would like to inflate the element with id=resultlist. Of course, I have developed the special Adapter and Layout for the content string of the ListView. The code looks like
ListView view = (ListView) findViewById(R.id.resultlist);
MyAdapter adapter = new MyAdapter(
new MyItem(R.drawable.class_01, "AUTO", 1, 0.0f),
new MyItem(R.drawable.class_02, "BUS", 2, 0.0f),
);
view.setAdapter(adapter);
setContentView(v开发者_运维百科iew);
But it works wrong. I can't see anything on device. (I'm sure I must use anywhere here my xml layout for ListView string and LayoutInflater instance, but where???)
Thanks.
Do you call "setContentView" on the entire activity layout somewhere? If not, that would likely explain the problem.
精彩评论