ListView控件不填充或的WebView占用整个屏幕? [英] ListView not populating, or WebView taking up entire screen?

查看:167
本文介绍了ListView控件不填充或的WebView占用整个屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有code应该填充我的ListView在我UrlListFragment,但是当我运行它,我看不出有任何的影响。
我把这个问题搁置在我的WebView工作,发现,一旦我打开一个URL,它使用整个屏幕。
我不知道这意味着没有被填充的ListView我的,所以它不占用空间,所以的WebView占据整个屏幕,或者WebView中占用了整个屏幕无论在ListView是否被填充或没有。

I have code that should populate my ListView in my UrlListFragment, but when I run it I see no effect. I put the problem aside to work on my WebView, and found that once I load a URL it uses the entire screen. I'm not sure if this means my ListView isn't being populated, so it doesn't take up space, so the WebView takes up the entire screen, or if the WebView is taking up the entire screen regardless of whether the ListView is being populated or not.

我填充我的ListView是这样的:

I populate my ListView like this:

    View returnView = inflator.inflate(R.layout.url_fragment, container, false);

    ListView listView1 = (ListView) returnView.findViewById(R.id.mylist);        
    String[] items = { "http://mobile.cs.fsu.edu/android", "http://www.google.com", "http://my-favoriate-website.com" };        
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, items);        
    listView1.setAdapter(adapter);

    return returnView;

和我的主要XML是这样的:

And my main XML is this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
</FrameLayout>

我把片段在主体布局programattically是这样的:

I place the Fragments in the main layout programattically like this:

    FragmentManager manager = getFragmentManager();
    FragmentTransaction trans = manager.beginTransaction();
    UrlListFragment urlfragment = new UrlListFragment();
    MyWebFragment webfragment = new MyWebFragment();
    trans.add(R.id.fragment_container, urlfragment, "my_url_fragment");
    trans.add(R.id.fragment_container, webfragment, "my_web_fragment");
    trans.commit();

还有什么问题是这样的,我的ListView只是没有出现,我的WebView占据整个屏幕?

What could the problem be such that my ListView just doesn't appear and my WebView takes up the entire screen?

推荐答案

您应该使用这种构造

 ArrayAdapter(Context context, int resource, int textViewResourceId, T[] objects)

这里的一切是一样的了你编写但在textViewResourceId您使用android.R.id.text1

where everything is the same as u wrote but in textViewResourceId you use android.R.id.text1

这篇关于ListView控件不填充或的WebView占用整个屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆