yhlm1994
2016-04-16 08:39
采纳率: 0%
浏览 1.6k

关于android中listview点击item没有反应

public class MapActivity extends BasePagerActivity {
private MapView mMapView = null;
private BaiduMap mBaiduMap;
private ListView map_menu_lv;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
initData();
}

@Override
public void initData() {
    base_tv_title.setText("街景秀");
    SDKInitializer.initialize(getApplicationContext());
    View view = View.inflate(MapActivity.this, R.layout.map, null);
    map_menu_lv = (ListView) view.findViewById(R.id.map_menu_lv);
    map_menu_lv.setAdapter(new MapMenuListViewAdapter(MapActivity.this));
    weibo_menu.setVisibility(View.VISIBLE);
    weibo_menu.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            //Toast.makeText(MapActivity.this, "wo", 1).show();
            map_menu_lv.setVisibility(View.VISIBLE);
        }
    });

    mMapView = (MapView) view.findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(15.0f);
    mBaiduMap.setMapStatus(msu);
    **map_menu_lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            // TODO Auto-generated method stub
            switch (arg2) {
            case 0:
                mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
                break;
            case 1:
                mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
                break;
            case 2:
                if(mBaiduMap.isTrafficEnabled()){
                    mBaiduMap.setTrafficEnabled(false);
                }else{
                    mBaiduMap.setTrafficEnabled(true);
                }
                break;

            default:
                break;**
            }
        }
    });
    base_fr.addView(view);
}

@Override
protected void onDestroy() {
    super.onDestroy();
    // 在activity执行onDestroy时执行mMapView.onDestroy(),实现地图生命周期管理
    mMapView.onDestroy();
}

@Override
protected void onResume() {
    super.onResume();
    // 在activity执行onResume时执行mMapView. onResume (),实现地图生命周期管理
    mMapView.onResume();
}

@Override
protected void onPause() {
    super.onPause();
    // 在activity执行onPause时执行mMapView. onPause (),实现地图生命周期管理
    mMapView.onPause();
}

}

请问标识出的部分为什么不能起到切换百度地图状态的功能?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • 月盡天明 2016-04-16 12:26
    评论
    解决 无用
    打赏 举报
  • ChangeM丶 2016-05-15 09:49

    我看你的类都没有实现点击事件的接口,你是怎么写的setOnClickListener

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题