Wednesday, August 17, 2011

How To Replace Image with another in Button click in Android

This very simple programme and it is very good for Android beginners. Those who new to Android and want to learn android, for them this may useful.

Java Code

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class MytestdroidActivity extends Activity implements OnClickListener {


    Button b1;
    ImageView iw;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

       b1 = (Button) findViewById(R.id.button1);
       b1.setOnClickListener(this); 

       iw = (ImageView) findViewById(R.id.icon);
    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        if (v == b1)
        {
            iw.setImageResource(R.drawable.camara);
        }

    }
}

XML Code









you should have 2 images in your drawable folder call icon and camera

Wednesday, July 20, 2011

Beginning

Hello Everybody.......... I am going to start a my new blog about technology with related to Android OS Phones. I am new to Android development but I want to share my experience with others and get your solutions for my problems.

I am love to work with Android. So we will start...