繁体   English   中英

仅在CardScrollView中的特定卡上设置onItemClickListener?

[英]Set onItemClickListener on only a particular card in CardScrollView?

我正在用Google Glass制作测验应用程序。 单击主要活动(这是一个问题)之后,将用户带到mCardScrollView(这是主要活动中的问题的答案)的卡片列表,我希望用户仅在正确输入后才被带到下一个问题单击选项(即,cardscrollview中的卡片)。

目前,我正在使用以下itemclicklistener,它将每个卡片变成可点击的项目,

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();

我正在尝试对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

谢谢!

简单的if-logic逻辑可以识别出您不想要的卡片,并且返回true即可执行您想要的操作,而无需执行任何操作。

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (!aClickableCard) {
        return true;
    }
    // ...
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM