Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在卡片回收器视图中添加web视图_Android_Iframe_Webview_Android Recyclerview - Fatal编程技术网

Android 在卡片回收器视图中添加web视图

Android 在卡片回收器视图中添加web视图,android,iframe,webview,android-recyclerview,Android,Iframe,Webview,Android Recyclerview,我想有一个卡回收的看法。 在这些卡片中,我想为iframe放置一个webView。 基本上,我想有一个使用iframe和recycler视图的视频列表。 我已经完成了以下操作,但绑定函数中存在问题。 输出没有显示任何内容 主要活动 public class MainActivity extends AppCompatActivity { private RecyclerView recyclerView; private RecyclerView.Adapter adapter

我想有一个卡回收的看法。 在这些卡片中,我想为iframe放置一个webView。 基本上,我想有一个使用iframe和recycler视图的视频列表。 我已经完成了以下操作,但绑定函数中存在问题。 输出没有显示任何内容

主要活动

public class MainActivity extends AppCompatActivity {

    private RecyclerView recyclerView;
    private RecyclerView.Adapter adapter;
    private RecyclerView.LayoutManager layoutManager;
    private recycle_adapter recycleAdapter;
    private List<url> urlList;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        recyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);

        urlList = new ArrayList<>();
        adapter = new recycle_adapter(this,urlList);

        // use this setting to improve performance if you know that changes
        // in content do not change the layout size of the RecyclerView
        recyclerView.setHasFixedSize(true);

        // use a linear layout manager
        layoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(adapter);

        prepareurl();
    }

    private void prepareurl(){
        String[] url_list = new String[]{"<html><body><iframe class=\\\"youtube-player\\\" type=\\\"text/html\\\" width=\\\"400\\\"" +
                " height=\\\"200\\\" src=\\\"http://www.youtube.com/embed/bIPcobKMB94\\\" frameborder=\\\"0\\\"></body></html>"};



        url url=new url(url_list[0]);
        urlList.add(url);

        url=new url(url_list[0]);
        urlList.add(url);

        url=new url(url_list[0]);
        urlList.add(url);

        url=new url(url_list[0]);
        urlList.add(url);

        adapter.notifyDataSetChanged();
    }
活动\u main.xml

    <?xml version="1.0" encoding="utf-8"?>

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.recycle.MainActivity">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/my_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical" />

</RelativeLayout>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView
        android:id="@+id/card"
        android:padding="4dp"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:background="#456345">

        <WebView
            android:id="@+id/web"
            android:layout_width="match_parent"
            android:layout_height="200dp" />

    </android.support.v7.widget.CardView>

</LinearLayout>

card.xml

    <?xml version="1.0" encoding="utf-8"?>

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.recycle.MainActivity">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/my_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical" />

</RelativeLayout>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView
        android:id="@+id/card"
        android:padding="4dp"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:background="#456345">

        <WebView
            android:id="@+id/web"
            android:layout_width="match_parent"
            android:layout_height="200dp" />

    </android.support.v7.widget.CardView>

</LinearLayout>

尝试这样更改prepareurl()

private void prepareurl(){
    String[] url_list = new String[]{"<html><body><iframe class=\\\"youtube-player\\\" type=\\\"text/html\\\" width=\\\"400\\\"" +
            " height=\\\"200\\\" src=\\\"http://www.youtube.com/embed/bIPcobKMB94\\\" frameborder=\\\"0\\\"></body></html>"};



    url url=new url(url_list[0]);
    urlList.add(url);
    adapter.notifyItemChanged(urlList.size());

    url=new url(url_list[0]);
    urlList.add(url);
    adapter.notifyItemChanged(urlList.size());

    url=new url(url_list[0]);
    urlList.add(url);
    adapter.notifyItemChanged(urlList.size());

    url=new url(url_list[0]);
    urlList.add(url);
    adapter.notifyItemChanged(urlList.size());
}
private void prepareurl(){
字符串[]url_list=新字符串[]{”“};
url=新url(url_列表[0]);
添加(url);
adapter.notifyItemChanged(urlist.size());
url=新url(url_列表[0]);
添加(url);
adapter.notifyItemChanged(urlist.size());
url=新url(url_列表[0]);
添加(url);
adapter.notifyItemChanged(urlist.size());
url=新url(url_列表[0]);
添加(url);
adapter.notifyItemChanged(urlist.size());
}