Code example for ImageButton

Methods: setImageBitmap, setEnabled, setLayoutParams, setOnClickListener

0
 
			LinearLayout lin=new LinearLayout(ctx);
			LayoutParams lp=new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT,1);
			 
			lin.setOrientation(LinearLayout.HORIZONTAL);
			ImageButton myLocation=new ImageButton(ctx);
			 
			myLocation.setImageBitmap(ctx.getOverlay().getPhoneIcon());
			myLocation.setLayoutParams(lp);
			myLocation.setEnabled(ctx.getOverlay().hasPhonePos());
			lin.addView(myLocation);
			ImageButton ufoLocation=new ImageButton(ctx);
			ufoLocation.setImageBitmap(ctx.getOverlay().getKopterIcon());
			ufoLocation.setLayoutParams(lp);
			 
			lin.addView(ufoLocation);
			ImageButton homeLocation=new ImageButton(ctx);
			homeLocation.setImageBitmap(ctx.getOverlay().getHomeIcon());
			 
			homeLocation.setLayoutParams(lp);
			lin.addView(homeLocation);
			 
			alert.setView(lin);
			alert.setTitle("Place WayPoint").setMessage("Where should I place the Waypoint?");
			 
			final AlertDialog alert_dlg=alert.show();
 
			ufoLocation.setOnClickListener(new View.OnClickListener() {
				@Override 
				public void onClick(View arg0) {
					ctx.getOverlay().ufopos2wp();
					alert_dlg.hide();
				}}  ); 
			 
			 
 
			homeLocation.setOnClickListener(new View.OnClickListener() {
				@Override 
				public void onClick(View arg0) {
					ctx.getOverlay().homepos2wp();
					alert_dlg.hide();
				}}  ); 
			 
 
			myLocation.setOnClickListener(new View.OnClickListener() {
				@Override 
				public void onClick(View arg0) {
					ctx.getOverlay().phonepos2wp();
					alert_dlg.hide();
				}}  );