我正在创建一个简单的Android应用程序,它有一个webview,应该显示一个url。当我将网址设为google.com或facebook.com时,它会正确加载,但是当我提供我的网址(qbo.intuit.com)时,它不会加载并提供“未捕获的TypeError:无法读取属性'getItem'的null “错误。 我在这里粘贴我的代码。我使用的是Compile sdk版本:API 22:Android 5.1(Lollipop),版本 - Android Studio 1.4,内部版本号:AI-141.2288178,Android SDK工具:24.4.0,jdk1.7.0_80。存在类似的问题,但它对我没有帮助。请帮助我是android的新手。 MainActivity.java
public JsonResult Grid(string sidx, string sord, int page, int rows)
{
int pageIndex = Convert.ToInt32(page) - 1;
int pageSize = rows;
IEnumerable<Student> StudentData = db.Students.ToList();
int totalRecords = StudentData.Count();
var totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows);
if (sord.ToUpper() == "DESC")
{
StudentData = StudentData.OrderByDescending(s => s.Id);
StudentData = StudentData.Skip(pageIndex * pageSize).Take(pageSize);
}
else
{
StudentData = StudentData.OrderBy(s => s.Id);
StudentData = StudentData.Skip(pageIndex * pageSize).Take(pageSize);
}
var jsonData = new
{
total = totalPages,
page,
records = totalRecords,
rows = StudentData
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
[HttpPost]
[ValidateAntiForgeryToken]
public string Create([Bind(Exclude = "Id")] Student student)
{
string msg;
try
{
if (ModelState.IsValid)
{
db.Students.Add(student);
db.SaveChanges();
msg = "Saved Successfully";
}
else
{
msg = "Validation data not successfull";
}
}
catch (Exception ex)
{
msg = "Error occured:" + ex.Message;
}
return msg;
}
public string Edit(Student student)
{
string msg;
try
{
if (ModelState.IsValid)
{
db.Entry(student).State = EntityState.Modified;
db.SaveChanges();
msg = "Saved Successfully";
}
else
{
msg = "Validation data not successfull";
}
}
catch (Exception ex)
{
msg = "Error occured:" + ex.Message;
}
return msg;
}
//Deletes the product
public string Delete(int Id)
{
Student student = db.Students.Find(Id);
db.Students.Remove(student);
db.SaveChanges();
return "Deleted successfully";
}
AndriodManifest.xml
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String url= "https://qbo.intuit.com/";
WebView view= (WebView) this.findViewById(R.id.webView);
final WebViewClient client = new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
};
WebSettings settings = view.getSettings();
settings.setJavaScriptEnabled(true);
view.setWebViewClient(client);
view.loadUrl(url);
}
<?xml version="1.0" encoding="utf-8"?>
答案 0 :(得分:160)
你需要做
WebSettings settings = webView.getSettings();
settings.setDomStorageEnabled(true);