java - Moving ImageView on HorizontalScrollView -


i displaying panoramic photo, , want imageview move according sensor orientation (my phone's orientation determines image view , it's wide display entirely @ once). when invoke methods change imageview (e.g. setx) application crashes. doing in ui thread, don't know why doesn't work. code refers sensor works fine.

any appreciated.

public class imageactivity extends activity { private imageview imageview; private locationmanager locationmanager; private string provider; private sensormanager sensormanager; public float val = 0;  @override protected void oncreate(bundle savedinstancestate) {      super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_image);     locationmanager = (locationmanager) getsystemservice(context.location_service);     criteria criteria = new criteria();     provider = locationmanager.getbestprovider(criteria, false);     location location = locationmanager.getlastknownlocation(provider);     sensormanager = (sensormanager) getsystemservice(sensor_service);     sensor sensor = sensormanager.getdefaultsensor(sensor.type_orientation);     sensormanager.registerlistener(new customorientationlistener(), sensor,                              sensormanager.sensor_delay_game);      //imageview = (imageview) findviewbyid(r.id.imageview1);      }   class customorientationlistener implements sensoreventlistener {        public customorientationlistener() {}        @override       public void onaccuracychanged(sensor sensor, int accuracy) {}        @override       public void onsensorchanged(sensorevent event) {           final float[] values;           if(event.sensor.gettype() == sensor.type_orientation){               values = event.values;               runonuithread(new runnable(){                  @override                 public void run() {                     imageview.settranslationx((int)values[0]);                  }                });           }        }    } 

}

yes, have android sdk on pc, test app on phone, don't know how read logs, cause don't know whe


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -