0

I am making a quiz app in the google glass. After the clicking the main activity (Which is a question) the user is taken to a list of cards, in mCardScrollView (which are answers to the question in main activity), I want user to be taken to the next question only after the correct option (i.e card in cardscrollview) is clicked.

Currently I am using the following itemclicklistener which turns every card to a clickable item,

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // Plays disallowed sound to indicate that TAP actions are not supported.
            AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            am.playSoundEffect(Sounds.DISALLOWED);

            Toast.makeText(Questionactivity.this, "this is selected : " + position, Toast.LENGTH_SHORT).show();
            //mCardScrollView.deactivate();


            Intent gotoquestion;
            gotoquestion = new Intent(Questionactivity.this, MainActivity.class);
            startActivity(gotoquestion);
            finish();

And I am trying to do something as follows on one of the card in cardscrollview,

       mCards.add(new CardBuilder(this, CardBuilder.Layout.COLUMNS)
            .setText("This card has a mosaic of puppies.")
            .setFootnote("Aren't they precious?")
            .addImage(R.drawable.ic_glass_logo));
            .View.OnClickListener

Thanks!

Bill Mote
  • 12,644
  • 7
  • 58
  • 82
ledzee
  • 301
  • 2
  • 3
  • 16

1 Answers1

0

Simple if-logic to identify the cards you don't want with a return true should do what you want without performing any action.

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (!aClickableCard) {
        return true;
    }
    // ...
}
Bill Mote
  • 12,644
  • 7
  • 58
  • 82
  • Sorry. You completely changed the question. You need to ask another question rather than adding a "part 2" -- doubly so when part 2 is entirely different. – Bill Mote Mar 24 '15 at 11:50