ListView没有出现在应用程序中

时间:2012-02-13 11:46:35

标签: android listview listactivity

我试图在我的标签功能下填充我的列表视图但由于某种原因它没有出现在我的应用程序中。我在一个外部项目中对代码进行了采样,但它确实有效,所以我不确定为什么它没有出现。我是否在清单中实施了错误的活动,或者我是否有相反的代码。选择按钮时没有错误或logcat问题。它只是标签下方的空白页面。页面加载但没有列表。感谢

XML File
<?xml version="1.0" encoding="utf-8"?>
<!--  Single List Item Design -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/label"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dip"
    android:textSize="16dip"
    android:textStyle="bold" >
</TextView>

ListmoreActivity

package workout.fitty;

import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;


public class ListmoreActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // storing string resources into Array
    String[] adobe_products = getResources().getStringArray(R.array.adobe_products);

    // Binding resources Array to ListAdapter
    this.setListAdapter(new ArrayAdapter<String>(this, R.layout.main, R.id.label, adobe_products));

}
}

清单中的活动添加如:

<activity android:name=".ListmoreActivity" />

以防万一

1 个答案:

答案 0 :(得分:1)

你从代码开始就错了,请参考下面的链接来学习android中的listview ...

http://www.vogella.de/articles/AndroidListView/article.html