Hey I was wondering how you make it so that when an image button is pushed it changes color to show it was pushed.
DragonFruitActivity.java
package com.Dragon_Fruit;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageButton;
public class DragonFruitActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageButton playbutton = (ImageButton) findViewById(R.id.playbutton); playbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
setBackgroundResource(R.drawable.playbuttonselected);
// TODO Auto-generated method stub
startActivity(new Intent(DragonFruitActivity.this, playbutton.class));
}
private void setBackgroundResource(int playbuttonselected) {
// TODO Auto-generated method stub
}
});
ImageButton settingsbutton = (ImageButton) findViewById(R.id.settingsbutton); settingsbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
startActivity(new Intent(DragonFruitActivity.this, settingsbutton.class));
}
});
}
}
So the new Activity should be:
package com.Dragon_Fruit;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageButton;
public class DragonFruitActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageButton playbutton = (ImageButton) findViewById(R.id.playbutton); playbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
arg0.setBackgroundResource(R.drawable.playbuttonselected);
// TODO Auto-generated method stub
startActivity(new Intent(DragonFruitActivity.this, playbutton.class));
}
});
ImageButton settingsbutton = (ImageButton) findViewById(R.id.settingsbutton); settingsbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
startActivity(new Intent(DragonFruitActivity.this, settingsbutton.class));
}
});
}
}