我有15个元素的数组... mObjects并有7个文本视图要显示。起初我在TextView数组中加载7然后当用户继续单击文本视图应该得到更新,即如果用户获得第三个元素,那么它应该以列表的方式更新第三个Texvire与下一个mObject ....我的逻辑适用于填充的前7个元素,但我将如何继续添加mObjects ......
中的元素解释更多:如果找到textview的第3个元素,则第4个textview变为3rd ...第5个变为第4个,第7个应该从mObjects添加新文本..直到数组的15个元素
这里是7个元素的逻辑,但没有得到如何将第8个元素添加到mObjects中的15个元素
public void onClick(View pressed){
boolean tvFound = false; //have we found the clicked tv yet?
for(int i=0;i<mTextViews.length;i++){ //loop through all tvs
if(pressed.getId() == mTextViews[i]){ //if this is the tv that was clicked on
tvFound = true;
}
if(tvFound){ // if we have found the tv that was clicked on
if(i<mTextViews.length-1){ //if we arent on the last tv
mTextViews[i].setText(mTextviews[i+1].getText()); //then replace txt with next tvs text
}else{ //if we ARE on the last tv
mTextViews[i].setText(""); //replace text with nothing
}
}
}
}