0

For example like,

View v = MapActivity.class;

below works as an activity but it doesnt work when i try to build the view with an adapter.

    setContentView(R.layout.zoommain);

mZoomControl = new DynamicZoomControl();

mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.image800x600);

mZoomListener = new LongPressZoomListener(getApplicationContext());
mZoomListener.setZoomControl(mZoomControl);

//not working... loading custom view
mZoomView = (ImageZoomView)findViewById(R.id.zoomview);
//mZoomView = (ImageZoomView)context.getResources().findViewById(R.id.zoomview);
//context.getResources()
mZoomView.setZoomState(mZoomControl.getZoomState());
mZoomView.setImage(mBitmap);
mZoomView.setOnTouchListener(mZoomListener);

mZoomControl.setAspectQuotient(mZoomView.getAspectQuotient());

resetZoomState();

1 Answer 1

0

From http://developer.android.com/reference/android/app/Activity.html

java.lang.Object
   ↳    android.content.Context
       ↳    android.content.ContextWrapper
           ↳    android.view.ContextThemeWrapper
               ↳    android.app.Activity

View is not part of the hierarchy. View v = MapActivity.class; doesn't make much sense.

What you can do, if View is part of an Activity in the same app, is:

View view = findViewById(R.id.zoommain);

Assuming that you gave an id zoomain to your main layout.

Alternatively, you can create your own custom layout, implementing the custom Listener, and then reuse it in more than one Activity.

1
  • Thank you very much. This is the explanation i was needing. Apr 26, 2011 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.