一个web视图下一个ListView [英] A ListView under a WebView

查看:140
本文介绍了一个web视图下一个ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个Android应用程序中显示的论坛。
文章主要内容是在的WebView ,我想要把答案变成的ListView 下主要的文章。

I am writing an Android app to display a forum. The content of the main article is in a WebView, and I'd like to put the answers into a ListView under the main article.

<?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:background="@drawable/bg"
    android:orientation="vertical" >

    <WebView
        android:id="@+id/content"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        //android:layout_weight="1.0"
        android:background="@drawable/bg"
        android:cacheColorHint="#00000000"
        android:textColor="#FFDEC2" />

    <ListView

        android:id="@+id/contentlist"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

下面的的ListView 不显示在所有。如果启用

Here the ListView isn't displayed at all. If I enable

android:layout_weight="1.0"

画面被分割,两者都显示,但的ListView 应当根据的WebView ,以便有是两个只有一个滚动条。

the screen gets split, both are shown, but the ListView should be under the WebView, so that there is just one scrollbar for both.

我觉得这篇文章: Android的布局 - ListView和下面的EditText 是关于我的问题,但我不明白如何编辑的这个code的网站适合我的问题。

I think this article: Android layout - listview and edittext below is about my problem, but I don't understand how to edit the code of this site to fit to my problem.

谁能帮我吗?

推荐答案

Raybritton是正确的。你不能有一个ListView和Web视图共享相同的滚动条。你不能巢scrollviews。

Raybritton is correct. You cannot have a ListView and a Web view share the same scrollbar. You cant nest scrollviews.

这听起来像你需要做的就是创建一个ListView适配器。这样,您可以创建列表中的每一行的自定义视图。

What it sounds like you will need to do is create a ListView adapter. This way you can create a custom view for each row of the list.

请按照下面的例子:
http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/

然后将里面的布置一个web视图并设置其知名度,飘。当你准备把它出现在code将其设置为可见。状态ListView中只有2行。这两个行会共享相同的布局,但是这是你指定每个项目的个人知名度,使行看起来不同。

Then place a WebView inside the layout and set its visibility to "Gone". When you are ready to have it appear set it to "Visible" in the code. State that the ListView only has 2 rows. Both rows will share the same layout, but this is where you specify the individual visibility of each item to make the rows look different.

所以长话短说:熟悉的ListView适配器和隐藏的看法。

So long story short: become familiar with ListView adapters and hiding views.

希望是有道理的!

这篇关于一个web视图下一个ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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