我有静态import UIKit
import WebKit
class ViewController: UIViewController {
@IBOutlet weak var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: "https://mit.gsv.dk")!
webView.load(URLRequest(url: url))
var scrw = webView.bounds.size.width
scrw = 2000
/*
let javascript = "document.querySelector('meta[name=viewport]').setAttribute('content', 'width=\(scrw);', false); "
webView.evaluateJavaScript(javascript)
*/
var scriptContent = "var meta = document.createElement('meta');"
scriptContent += "meta.name='viewport';"
scriptContent += "meta.content='width=device-width';"
scriptContent += "document.getElementsByTagName('head')[0].appendChild(meta);"
webView.evaluateJavaScript(scriptContent, completionHandler: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
& ArrayList
从CustomAdapter
Broadcastreceiver
当数据被更改时,我的public static ArrayList<AppDetail> apps;
public static CustomAdapter adapter;
被调用,我的列表更新了新项目,但RecyclerView显示旧数据新项目未被看到
Broadcastreceiver
这是我的public class AppListener extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent arg1)
{
// TODO Auto-generated method stub
Log.d("Akshay", "there is a broadcast");
apps=null;
loadApps(context);
}
函数
loadApps()
答案 0 :(得分:0)
您好@Akshay Katariya可以尝试下面的代码
private void loadApps(Context context){
if (apps == null)
{
if(adapter != null)
adapter.notifyDataSetChanged();
else
yourRecyclerviewObject.setadapter(adapter);
}
}
}
请检查。