I started out with the thought that I could have an ImageView and make it tappable and got nowhere with it.
I then found ImageButton which supposedly is the way to go (please correct)
I then found how to turn off the horrid border with android:background="@null"
But please oh please how on earth do you obtain and process the tap/click whatever terminology to use?
I tried this:
java Code:
public class TheApp extends Activity {
Intent i;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageButton slide = (ImageButton) this.findViewById(R.id.drapper );
slide.
setOnClickListener(new Button.
OnClickListener() {
public void onClick
(View view
) {
showSlide();
}
});
}
private void showSlide() {
Log.d("show me", "the money");
}
}
The simulator fails to load program with a force quit message!
Then I try this:
java Code:
public class TheApp
extends Activity
implements View.
OnClickListener {
Intent i;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageButton slide = (ImageButton) this.findViewById(R.id.drapper );
slide.setOnClickListener(this);
}
public void onClick
(View v
) {
Intent i;
switch (v.getId()) {
case R.id.drapper:
i = new Intent(this, Drapper.class);
startActivity(i);
break;
}
}
}
I have spend ages trudging the web trying to find the answer and am lost!