I know I'm heading in the right direction, I just can't seem to make
it work!

MAIN.JAVA

        public static final int SPEED_ABILITY = 1;

        /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        ImageButton speed_ability_button =
(ImageButton)findViewById(R.id.speed_ability_button);
 
speed_ability_button.setBackgroundDrawable(getResources().getDrawable(R.drawable.speed_any));
        speed_ability_button.setOnClickListener(new
View.OnClickListener(){
                public void onClick(View view){
                        Intent get_speed_ability = new Intent(view.getContext(),
Speed_ability.class);
                        startActivityForResult (get_speed_ability, 
SPEED_ABILITY);
                }
        });

    protected void onActivityResult(int requestCode, int resultCode,
Intent data){
                switch(requestCode) {
                case SPEED_ABILITY:
                        String speeda = data.getStringExtra("speeda_choice");
                        if (resultCode == RESULT_OK && speeda == "any"){
                                ImageButton speed_ability_button =
(ImageButton)findViewById(R.id.speed_ability_button);
        
speed_ability_button.setBackgroundDrawable(getResources().getDrawable(R.drawable.speed_any));
                        }
                        if (resultCode == RESULT_OK && speeda == "boot"){
                                ImageButton speed_ability_button =
(ImageButton)findViewById(R.id.speed_ability_button);
        
speed_ability_button.setBackgroundDrawable(getResources().getDrawable(R.drawable.speed_boot));
                        }
                }
        }
}


Speed_ability.JAVA

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.speed_ability);

        ImageButton speed_any = (ImageButton)
findViewById(R.id.speed_any_selection);
        speed_any.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent set_as_any_speed = new Intent();
                String speeda_choice = "any";
                set_as_any_speed.putExtra("speeda_choice",
speeda_choice);
                                setResult(RESULT_OK, set_as_any_speed);
                finish();
            }
        });

        ImageButton speed_boot = (ImageButton)
findViewById(R.id.speed_boot_selection);
        speed_boot.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent set_as_boot_speed = new Intent();
                String speeda_choice = "boot";
                set_as_boot_speed.putExtra("speeda_choice",
speeda_choice);
                                setResult(RESULT_OK, set_as_boot_speed);
                finish();
            }
        });
    }
}


On May 10, 9:25 am, TreKing <[email protected]> wrote:
> On Mon, May 10, 2010 at 8:49 AM, Tollas <[email protected]> wrote:
> > I've searched high and low for a way to do this, but have come up
> > with nothing.
>
> Search for startActivityForResut(), setResult() and onActivityResult().
>
> -------------------------------------------------------------------------------------------------
> TreKing - Chicago transit tracking app for Android-powered 
> deviceshttp://sites.google.com/site/rezmobileapps/treking
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow 
> athttp://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group 
> athttp://groups.google.com/group/android-beginners?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to