Skip to main content

Posts

Showing posts with the label onclick

Clickable widgets in android

The developer documentation has seemed to have failed me here. I can create a static widget without thinking, I can even create a widget like the analogue clock widget that will update itself, however, I can not for the life of me figure out how to create a widget that reacts to when a user clicks on it. Here is the best code sample that the developer documentation gives to what a widget activity should contain (the only other hint being the API demos, which only creates a static widget): public class ExampleAppWidgetProvider extends AppWidgetProvider { public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { final int N = appWidgetIds.length; // Perform this loop procedure for each App Widget that belongs to this provider for (int i=0; i<N; i++) { int appWidgetId = appWidgetIds[i]; // Create an Intent to launch ExampleActivity Intent intent = new Intent(context, ExampleActivity.c

javascript onclick combining 2 events does not work on ios (iPhone, iPad)

I'm combining 2 javascripts in the onclick to do 2 things: 1. Stop an audio player 2. Load and iframe that has a video The following code works on all browsers but not iOS (iPhone, iPad) <a class="aboutclick" href="#" onclick="stop2();document.getElementById('frame').innerHTML='&lt;iframe src=&quot;paul-on-paul.html&quot; width=&quot;100%&quot; height=&quot;600&quot; scrolling=&quot;no&quot; frameborder=&quot;no&quot;&gt;&lt;/iframe&gt;'"><img src="assets/video-cold.jpg" alt="paul-gregory-video" width="161" height="81" border="0" /></a> The stop2() in the beginning of the onclick code is what turns off the music player. (it's Flash audio player so it doesn't apply to iOS). Tapping on the image does nothing on the iPad, iPhone with this code present. If I remove stop2(); from the onclick c

<ToggleButton> onClickListener - changing drawable back to default

I've got this ToggleButton which is supposed to change the drawables (and functions) of some other buttons upon toggling on/off. So far i've only managed to make it work one way, by using this code. @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.main); toggle = (ToggleButton) findViewById(R.id.bRedGreen); toggle.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub minuskugle = (Button) findViewById(R.id.bBallhole); minuskugle.setBackgroundResource(R.drawable.redballinhole); } }); } How do you make it change the drawable back to default upon another click? _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __

Android ImageView onClickListener won"t work

I am using a View Object named CameraView that implements View and uses a Hud-Object to create the HUD for a game. In this Hud-Class i use a LinearLayout to place ImageViews. I want these ImageViews to be clickable and to be able to fire some Code on Click. Thats why I use the onClickListener for each of the ImageViews. But it won't work at all. Here is the specific Code of both classes: CameraView protected void onDraw(Canvas canvas) { //GameTimer hud.draw(canvas); // and make sure to redraw asap invalidate(); } HUD public class Hud{ public TextElement gameTimer; CameraView mCameraView; private HashMap<Integer, Item> mItems = new HashMap<Integer, Item>(); private Integer mScreenWidth; private Integer mScreenHeight; //private ImageView imgView; private HashMap<Integer, ImageView> imgViews = new HashMap<Integer, ImageView>(); private LinearLayout ll; public Hud(CameraView cameraView){ mCameraView = cameraView; mScreenWidth