화면의 일부를 스 와이프하려고합니다. 나는 이것을 위해 PageAdapter를 사용한다. 부분을 강타 나는 세 가지 활동
1 ShowMap
2 ShowAddress 내가 ShowMap 활동의 레이아웃의 ID를 얻기에 노력하고 있지만 예외를 찾을 수없는 자원을 보여주는 것활동 스 와이프 : - 리소스를 찾을 수 없음 예외
3. ShowContact 있습니다. 여기 MyPageAdapter 클래스
public class anyclass extends Activity{
private class MyPagerAdapter extends PagerAdapter {
public int getCount(){
return 3;
}
public Object instantiateItem(View collection, int position) {
LayoutInflater inflater = (LayoutInflater) collection.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
int resId = 0;
switch (position) {
case 0:
resId = showHotelContact();
break;
case 1:
resId = showHotelAddress();
break;
case 2:
resId = showHotelMap();
break;
}
View view = inflater.inflate(resId, null);
((ViewPager) collection).addView(view, 0);
return view;
}
}
public int showHotelMap()
{
Intent bookIntent = new Intent();
bookIntent.setClass(HotelMap.this,ShowMap.class);
startActivityForResult(bookIntent,RESID);
return RESID;
}
public int showHotelAddress()
{
int resId;
resId = R.layout.hoteladdress;
return resId;
}
public int showHotelContact()
{
int resId;
resId = R.layout.hotelcontact;
return resId;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
RESID = data.getIntExtra("SelectedBook", resultCode);
}
}
}
내가 showMap 레이아웃의 ID를 필요로하고 내가 내 PageAdapter에게 반환하려고하지만 예외를 보여주는 것 내 코드입니다. 그리고 ShowMap 액티비티입니다.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hotelmap);
int resId = R.layout.hotelmap;
Intent returnIntent = new Intent();
returnIntent.putExtra("SelectedBook",resId);
setResult(RESULT_OK,returnIntent);
finish();
MapView mapView = (MapView) findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(true);
mapView.setStreetView(true);
MapController mc = mapView.getController();
double lat = Double.parseDouble("48.85827758964043"); // latitude
double lon = Double.parseDouble("2.294543981552124"); // longitude
GeoPoint geoPoint = new GeoPoint((int)(lat * 1E6), (int)(lon * 1E6));
mc.animateTo(geoPoint);
mc.setZoom(15);
mapView.invalidate();
List<Overlay> mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.ic_launcher);
}
은 여기 내 로그 캣입니다.
12-31 13:14:26.740: E/AndroidRuntime(31140): android.content.res.Resources$NotFoundException: Resource ID #0x0
12-31 13:14:26.740: E/AndroidRuntime(31140): at android.content.res.Resources.getValue(Resources.java:1104)
12-31 13:14:26.740: E/AndroidRuntime(31140): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2342)
12-31 13:14:26.740: E/AndroidRuntime(31140): at android.content.res.Resources.getLayout(Resources.java:943)
12-31 13:14:26.740: E/AndroidRuntime(31140): at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
12-31 13:14:26.740: E/AndroidRuntime(31140): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-31 13:14:26.740: E/AndroidRuntime(31140): at com..HotelMap$MyPagerAdapter.instantiateItem(HotelMap.java:52)
12-31 13:14:26.740: E/AndroidRuntime(31140): at android.support.v4.view.PagerAdapter.instantiateItem(PagerAdapter.java:110)
12-31 13:14:26.740: E/AndroidRuntime(31140): at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:801)
12-31 13:14:26.740: E/AndroidRuntime(31140): at android.support.v4.view.ViewPager.populate(ViewPager.java:930)
12-31 13:14:26.740: E/AndroidRuntime(31140): at android.support.v4.view.ViewPager.populate(ViewPager.java:881)
를 시도? 'RESID' 값은 무엇입니까? – Faizan
onCreate 메소드에서 finish()를 제거하고 – Taruni
@Faizan을 시도하십시오. resId에서 레이아웃 ID를 가져오고이 맵을 표시하기 위해 pageAdapter 클래스로 리턴하려고합니다. –