0

これは私が持っているクラスであり、私にエラーを与えます:

public class ShowCarMapChild extends MapActivity {


private MapView mapView;
private Car car;
private String tag;





@Override
protected void onCreate(Bundle icicle) {
    // TODO Auto-generated method stub
    super.onCreate(icicle);
    Log.d("hemendik pasetan da?", "bai!!");
    setContentView(R.layout.car_map_view);
}

public void setCar(Car car){
    this.car = car;
}

public void setTag (String tag){
    this.tag = tag;
}

public String getTag (){
    return tag;
}

public View getMapView(Context context){
    Log.d("getMapView", "pass");
    setContentView(R.layout.car_map_view);
    LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
    View view = infalInflater.inflate(R.layout.car_map_view, null);
    setMap(view,context);
    return view;
}




public void setMap(View view, Context context){
    mapView = (MapView) view.findViewById(R.id.mapShowCarLocation);
    MapController mc = mapView.getController();
    mc.animateTo(car.getLocation());
    mc.setZoom(15);
    PinpointItem point = new PinpointItem(car.getLocation(), car, context);
    Drawable d = getResources().getDrawable(R.drawable.pinpoint);
    CustomPinpointOverlay overlay = new CustomPinpointOverlay(d);
    overlay.insertPinpoint(point);
    mapView.getOverlays().add(overlay);
}
@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}

}

レイアウト:car_map_view.xml

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="150dip"
android:orientation="vertical" >

    <com.google.android.maps.MapView
        android:id="@+id/mapShowCarLocation"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="0UFOPeLgKxoW8VGjdzV5QN6N53N7733i1kTFI3g"
        android:enabled="true" />
</LinearLayout>

タイトルで言ったように、エラーはsetContentViewを実行しているときです。また、このクラスを使用して、子として拡張可能なリストに入れようとしていることも言わなければなりません。残りのコードが必要な場合は、私に知らせてください。

ここから、getMapView()メソッドを呼び出します。BaseExpandableListAdapterからのものです

 public class ShowCarExpandListAdapter extends BaseExpandableListAdapter {

 ....

 public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View view,
        ViewGroup parent) {
    // TODO Auto-generated method stub

    if (view == null){
        if (groupPosition == 0){
            Log.d("getChildView", "pass");
            ShowCarMapChild mapChild = (ShowCarMapChild) getChild(groupPosition, childPosition);
            view = mapChild.getMapView(context);
            //LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
            //ShowCarMapChild mapChild = (ShowCarMapChild) getChild(groupPosition, childPosition);
            //view = infalInflater.inflate(R.layout.car_map_view, null);
            //MapView mv = mapChild.getMap(view, context);
            //mv.setTag(mapChild.getTag());

        }else{
            Log.d("getChildView", "pass from else");
            LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
            ShowCarExpandChild child = (ShowCarExpandChild) getChild(groupPosition, childPosition);
            view = infalInflater.inflate(R.layout.car_child, null);
            TextView tv = (TextView) view.findViewById(R.id.tvChild);
            tv.setText(child.getName());
            tv.setTag(child.getTag());
        }           
    }
    return view;
}

  .....
4

0 に答える 0