android listview 不显示,android – 片段中的ListView未显示

我有一个应用程序,其中有几个选项卡;与任何一个进行交互都会调用要显示的片段.不幸的是,当我切换到下面的片段时,我的listView没有出现,尽管有问题的列表被填充.非常感谢您提供的任何帮助.

片段的相关代码:

public class Fragment_1 extends SherlockFragment {

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){

//If time permits, I will try to make a Custom Adapter implemented with a TreeSet

TreeSet theSet = MainActivity.getInstance().datasource.GetAllWords();

ArrayList list = new ArrayList();

for(BlacklistWord i :theSet){

System.out.println(i.getWord());

list.add(i.getWord());

}

Collections.sort(list);

//Making BlackList

listView = new ListView(getActivity());

listView.findViewById(R.id.listview);

adapter = new ArrayAdapter(getActivity(), android.R.layout.simple_list_item_1, list);

listView.setAdapter(adapter);

((BaseAdapter) listView.getAdapter()).notifyDataSetChanged();

container.addView(listView);

return inflater.inflate(R.layout.blacklist, container, false);

// return inflater.inflate(R.layout.blacklist, container, false);

}

}

XML是

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

android:id="@+id/listview"

android:layout_width="match_parent"

android:layout_height="wrap_content" />

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值