[英]Set onItemClickListener on only a particular card in CardScrollView?
I am making a quiz app in the google glass. 我正在用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 (ie card in cardscrollview) is clicked.
单击主要活动(这是一个问题)之后,将用户带到mCardScrollView(这是主要活动中的问题的答案)的卡片列表,我希望用户仅在正确输入后才被带到下一个问题单击选项(即,cardscrollview中的卡片)。
Currently I am using the following itemclicklistener which turns every card to a clickable item, 目前,我正在使用以下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();
And I am trying to do something as follows on one of the card in cardscrollview, 我正在尝试对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! 谢谢!
Simple if-logic to identify the cards you don't want with a return true should do what you want without performing any action. 简单的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.