我使用下面的代码:
private Runnable returnRes = new Runnable() {
@Override
public void run() {
if(m_orders != null && m_orders.size() > 0){
m_adapter.notifyDataSetChanged();
for(int i=0;i<m_orders.size();i++)
m_adapter.add(m_orders.get(i));
}
m_ProgressDialog.dismiss();
m_adapter.notifyDataSetChanged();
}
};
Run Code Online (Sandbox Code Playgroud)
但奇怪的是,在列表填充之后,唯一可用的项目是列表中的第一件事,直接在下面的行将是空的,除非我向下拖出视图然后再返回然后它显示.我非常确定上面的代码是正确的,因为我遵循了一个教程.但是,我不能指望用户再次向下拖动以查看所涉及的内容......
另外,我只是注意到我的数据没有正确填充,因为这个警告会出现07-19 23:54:49.947: WARN/InputManagerService(58): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44eb97c0
,我很确定我的代码是正确的,以下是它停止的地方:
public View getView(int position, View convertView, ViewGroup parent){
View v = convertView;
if(v != null){
return v;
}
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.row, null);
Log.d("added", "g" + position);
Grade g = grades.get(position);
if(g != null){ …Run Code Online (Sandbox Code Playgroud) 首先,为另一个这样的问题道歉,但我似乎无法找到现有问题与我之间的相似之处,所以我走了
我的index.html如下:
<html><script id="employee-tpl" type="text/x-handlebars-template">
<div class='header'><a href='#' class="button header-button header-button-left">Back</a><h1>Map</h1></div>
<div data-role="content" id="content">
<div id="map_canvas" style="height:100%"></div>
</div>
</script></html>
Run Code Online (Sandbox Code Playgroud)
所以这是div的一部分,div包含地图.所以下一节是上面的'编译和调用'
============= EDITED ==============
var EmployeeView = function(employee){
function initMap(){
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
};
this.render = function(){
this.el.html(EmployeeView.template(employee));
return this;
};
this.initialize = function(){
this.el=$('<div/>');
};
this.initialize();
google.maps.event.addDomListener(window, "load", initMap);
}
EmployeeView.template = Handlebars.compile($("#employee-tpl").html());
Run Code Online (Sandbox Code Playgroud)
所以用上面的逻辑,不知怎的,我仍然得到以下错误:(
Uncaught TypeError: Cannot read property 'offsetWidth' of …Run Code Online (Sandbox Code Playgroud) 我有2个函数,函数A调用函数B,它对地址进行地理编码并将LatLng对象返回给函数A,但不知何故,函数A不等待函数B从Google返回结果.
function A() {
var address = document.getElementById("txtbox").value;
//geocoding here
var here = B(address);
if (here == null) {
console.log("seems like geocode didn't work, defaulting value");
Run Code Online (Sandbox Code Playgroud)
在功能B中
function B(address) {
var here;
geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address}, function(results, status) {
console.log("geocoding");
if (status == google.maps.GeocoderStatus.OK) {
console.log(results[0].geometry.location);
currentlatlng = results[0].geometry.location;
lng = currentlatlng.lng();
lat = currentlatlng.lat();
here = new google.maps.LatLng(lat, lng);
} else {
console.log("Geocode was not successful for the following reason: " + status);
}
}); …Run Code Online (Sandbox Code Playgroud)