android listview webview 不显示,Listview with webview

i'm trying to create a ListView with a Webview inside, but the app shows nothing.

Here my Code:

The MainActivity where I set the CustomAdapter

public class Web_in_list1Activity extends Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

ListView lv = (ListView)findViewById(R.id.listView2);

ListViewAdapter adapter = new ListViewAdapter(this);

lv.setAdapter(adapter);

}

}

getView of the CustomAdapter

Here I get the Layout for the ListView and ste the URL for the Webview

public View getView(int arg0, View convertView, ViewGroup arg2) {

// TODO Auto-generated method stub

LayoutInflater inflater = context.getLayoutInflater();

convertView = inflater.inflate(R.layout.listitem, null);

WebView wv = (WebView)convertView.findViewById(R.id.webview);

wv.getSettings().setJavaScriptEnabled(true);

wv.loadUrl("http://www.google.com");

convertView.setTag(wv);

return convertView;

}

main.xml

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_height="fill_parent"

android:layout_width="fill_parent"

android:orientation="vertical">

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_height="fill_parent"

android:id="@+id/listView2"

android:layout_width="fill_parent"/>

listitem.xml

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_height="fill_parent"

android:layout_width="fill_parent"

android:orientation="vertical">

android:id="@+id/webview"

android:layout_width="fill_parent"

android:layout_height="fill_parent"/>

CLOSED!

PROBLEM SOLVED WITH A SCROLLVIEW

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值